package com.kurumi.controller;

import java.io.IOException;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.jasper.tagplugins.jstl.core.ForEach;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.kurumi.domain.PractitionerVO;
import com.kurumi.pojo.RespondResult;
import com.kurumi.pojo.coding.CureInfo;
import com.kurumi.query.MedicalRecordQuery;
import com.kurumi.service.MedicalRecordDataManageService;
import com.kurumi.util.CSVUtil;
import com.kurumi.util.DateUtil;
import com.kurumi.util.ExcelUtil;
import com.kurumi.util.JavaDBFUtil;
import com.kurumi.util.JavaDBFUtils;
import com.kurumi.util.JsonUtil;
import com.kurumi.util.NumberUtils;
import com.kurumi.util.ObjectUtils;

@Controller
@RequestMapping("/data_manage")
public class MedicalRecordDataManageController {

	@Autowired
	private MedicalRecordDataManageService medicalRecordDataManageService;

	@GetMapping("/page_index_export")
	public String pageIndexExport(Model model){
		return "data_manage/page_index_export";
	}

	@GetMapping("/page_index_hqms_export")
	public String pageIndexHQMSExport(Model model){
		return "data_manage/page_index_hqms_export";
	}

	@GetMapping("/page_index_wt41_export")
	public String page_index_wt41_export(Model model){
		return "data_manage/page_index_wt41_export";
	}


	@GetMapping("/page_index_wt41_export_old")
	public String page_index_wt41_export_old(Model model){
		return "data_manage/page_index_wt41_export_old";
	}



	@GetMapping("/medical_record_delete_page")
	public String medicalRecordDeletePage(Model model){
		return "data_manage/medical_record_delete";
	}



	@PostMapping("/ajax_medical_record_delete")
	@ResponseBody
	public RespondResult ajaxMedicalRecordDelete(String visitGuid){
		RespondResult respondResult = null;
		try{
			int count = medicalRecordDataManageService.medicalRecordDelete(visitGuid);
			if(count == 1){
				respondResult = new RespondResult(true, RespondResult.successCode, "删除成功","删除成功");
			}else{
				respondResult = new RespondResult(true, RespondResult.errorCode, "删除失败","删除失败");
			}

		}catch (Exception e) {
			// TODO: handle exception
			respondResult = new RespondResult(false, RespondResult.errorCode, e.getMessage(), "");
		}

		return respondResult;
	}

	@GetMapping("/ajax_query_page_index")
	@ResponseBody
	public RespondResult ajaxQueryHomePage(MedicalRecordQuery params){
		RespondResult respondResult = null;

		try{
			List<Map<String,Object>> medicalRecords = new ArrayList<Map<String,Object>>();
			if(!params.queryUnEncodingEmpty()){
				medicalRecords = medicalRecordDataManageService.getMedicalRecordOfExport(params);
			}
			respondResult = new RespondResult(true, RespondResult.successCode, null, medicalRecords);
		}catch (Exception e) {
			// TODO: handle exception
			respondResult = new RespondResult(false, RespondResult.errorCode, e.getMessage(), "");
		}

		return respondResult;
	}


	@GetMapping("/page_index_hqms_to_dbf")
	public void pageIndexHQMSToDBF(MedicalRecordQuery params,String beyondDay,HttpServletResponse response) {
		OutputStream out = null;
		try{
			List<Map<String,Object>> medicalRecords = new ArrayList<Map<String,Object>>();
			if(!params.queryUnEncodingEmpty()){
				medicalRecords = medicalRecordDataManageService.getMedicalRecordOfExcel(params);
			}
			/*response.setContentType("octets/stream");*/
			/*response.setCharacterEncoding("GBK");*/
			response.setContentType("applicationnd.ms-excel");
			String title= "HQMS导出";
			StringBuilder downLoadFileName = new StringBuilder();
			downLoadFileName = new StringBuilder(
					"attachment;filename=");
			/*downLoadFileName.append(title).append(DateUtil.dateFormat(new Date()))
					.append(".xls");*/
			downLoadFileName.append(title).append(DateUtil.dateFormat(new Date()))
			.append(".dbf");
			String encodeStr = new String(downLoadFileName.toString().getBytes(
					"GB2312"), "ISO_8859_1");
			response.addHeader("Content-Disposition", encodeStr);
			out = response.getOutputStream();
			/*ExcelUtil.exportExcelOfPageIndex(out,medicalRecords);*/
			JavaDBFUtils.exportHQMSDBFOfPageIndex(out, medicalRecords);

		}catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}finally{
			if(out != null){
				try {
					out.flush();
				} catch (Exception e2) {
					// TODO: handle exception
				}
				try {
					out.close();
				} catch (Exception e2) {
					// TODO: handle exception
				}
			}

		}

	}


	@GetMapping("/page_index_to_excel")
	public void pageIndexToExcel(MedicalRecordQuery params,String beyondDay,HttpServletResponse response) {
		OutputStream out = null;
		try{
			List<Map<String,Object>> medicalRecords = new ArrayList<Map<String,Object>>();
			if(!params.queryUnEncodingEmpty()){
				medicalRecords = medicalRecordDataManageService.getMedicalRecordOfExcel(params);
			}
			/*response.setContentType("octets/stream");*/
			/*response.setCharacterEncoding("GBK");*/
			response.setContentType("applicationnd.ms-excel");
			String title= "首页导出";
			StringBuilder downLoadFileName = new StringBuilder();
			downLoadFileName = new StringBuilder(
					"attachment;filename=");
			/*downLoadFileName.append(title).append(DateUtil.dateFormat(new Date()))
					.append(".xls");*/
			downLoadFileName.append(title).append(DateUtil.dateFormat(new Date()))
			.append(".dbf");
			String encodeStr = new String(downLoadFileName.toString().getBytes(
					"GB2312"), "ISO_8859_1");
			response.addHeader("Content-Disposition", encodeStr);
			out = response.getOutputStream();
			/*ExcelUtil.exportExcelOfPageIndex(out,medicalRecords);*/
			JavaDBFUtil.exportDBFOfPageIndex1(out, medicalRecords);

		}catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}finally{
			if(out != null){
				try {
					out.flush();
				} catch (Exception e2) {
					// TODO: handle exception
				}
				try {
					out.close();
				} catch (Exception e2) {
					// TODO: handle exception
				}
			}

		}

	}




	/**
	 * 卫统首页导出
	 * @param response
	 */
	@RequestMapping("/getExportWtsy")
	public void getExportWtsy(HttpServletResponse response,String startTime,String endTime) {


		try {
			OutputStream out = response.getOutputStream();

			String excelName = "卫计统4-1病案首页";
			//转码防止乱码
			response.addHeader("Content-Disposition", "attachment;filename="+new String(excelName.getBytes("gb2312"), "ISO8859-1" )+".xlsx");
			//通过response获取文件输出流


		List<String> list = medicalRecordDataManageService.getMediclJson(startTime+" 00:00:00",endTime+" 23:59:59");

		String[] headerArr = { "USERNAME", "YLFKFS", "JKKH", "ZYCS", "BAH", "XM", "XB", "CSRQ", "NL", "GJ", "BZYZSNL",
				"XSECSTZ", "XSERYTZ", "CSD_SG", "CSD_SI", "CSD_QX", "CSD_DZ", "GG_SG", "GG_SI", "MZ", "SFZJLB", "SFZH",
				"ZY", "HY", "XZZ_SG", "XZZ_SI", "XZZ_QX", "XZZ_DZ", "DH", "YB1", "HKDZ_SG", "HKDZ_SI", "HKDZ_QX",
				"HKDZ_DZ", "YB2", "GZDWJDZMC", "GZDWJDZ_SG", "GZDWJDZ_SI", "GZDWJDZ_QX", "GZDWJDZ_DZ", "DWDH", "YB3",
				"LXRXM", "GX", "DZ_SG", "DZ_SI", "DZ_QX", "DZ_DZ", "DH2", "RYTJ", "ZZYLJGMC", "RYSJ", "RYSJS", "RYKB",
				"RYBF", "ZKKB", "ZKKB1", "ZKKB2", "CYSJ", "CYSJS", "CYKB", "CYBF", "SJZYTS", "MZZD", "JBBM", "ZYZD",
				"JBDM", "RYBQ", "QTZD1", "JBDM1", "RYBQ1", "QTZD2", "JBDM2", "RYBQ2", "QTZD3", "JBDM3", "RYBQ3",
				"QTZD4", "JBDM4", "RYBQ4", "QTZD5", "JBDM5", "RYBQ5", "QTZD6", "JBDM6", "RYBQ6", "QTZD7", "JBDM7",
				"RYBQ7", "QTZD8", "JBDM8", "RYBQ8", "QTZD9", "JBDM9", "RYBQ9", "QTZD10", "JBDM10", "RYBQ10", "QTZD11",
				"JBDM11", "RYBQ11", "QTZD12", "JBDM12", "RYBQ12", "QTZD13", "JBDM13", "RYBQ13", "QTZD14", "JBDM14",
				"RYBQ14", "QTZD15", "JBDM15", "RYBQ15", "WBYY", "H23", "BLZD", "JBMM", "BLH", "ICDO3", "ZGZDYJ", "YWGM",
				"GMYW", "SWHZSJ", "XX", "TJHL_T", "YJHL_T", "EJHL_T", "SJHL_T", "RH", "KZR", "YLZZ", "ZRYS", "ZZYS",
				"ZYYS", "ZRHS", "JXYS", "SXYS", "BMY", "BAZL", "ZKYS", "ZKHS", "ZKRQ", "SSJCZBM1", "SSJCZRQ1", "SSJB1",
				"SSLX1", "SSJCZMC1", "SZ1", "YZ1", "EZ1", "QKDJ1", "QKYHLB1", "MZFS1", "MZYS1", "SSJCZBM2", "SSJCZRQ2",
				"SSJB2", "SSLX2", "SSJCZMC2", "SZ2", "YZ2", "EZ2", "QKDJ2", "QKYHLB2", "MZFS2", "MZYS2", "SSJCZBM3",
				"SSJCZRQ3", "SSJB3", "SSLX3", "SSJCZMC3", "SZ3", "YZ3", "EZ3", "QKDJ3", "QKYHLB3", "MZFS3", "MZYS3",
				"SSJCZBM4", "SSJCZRQ4", "SSJB4", "SSLX4", "SSJCZMC4", "SZ4", "YZ4", "EZ4", "QKDJ4", "QKYHLB4", "MZFS4",
				"MZYS4", "SSJCZBM5", "SSJCZRQ5", "SSJB5", "SSLX5", "SSJCZMC5", "SZ5", "YZ5", "EZ5", "QKDJ5", "QKYHLB5",
				"MZFS5", "MZYS5", "SSJCZBM6", "SSJCZRQ6", "SSJB6", "SSLX6", "SSJCZMC6", "SZ6", "YZ6", "EZ6", "QKDJ6",
				"QKYHLB6", "MZFS6", "MZYS6", "SSJCZBM7", "SSJCZRQ7", "SSJB7", "SSLX7", "SSJCZMC7", "SZ7", "YZ7", "EZ7",
				"QKDJ7", "QKYHLB7", "MZFS7", "MZYS7", "SSJCZBM8", "SSJCZRQ8", "SSJB8", "SSLX8", "SSJCZMC8", "SZ8",
				"YZ8", "EZ8", "QKDJ8", "QKYHLB8", "MZFS8", "MZYS8", "RJQK", "WCQK", "BYQK", "LYFS", "YZZY_YLJG",
				"WSY_YLJG", "SFZZYJH", "MD", "RYQ_T", "RYQ_XS", "RYQ_F", "RYH_T", "RYH_XS", "RYH_F", "ZFY", "ZFJE",
				"YLFUF", "ZLCZF", "HLF", "QTFY", "BLZDF", "SYSZDF", "YXXZDF", "LCZDXMF", "FSSZLXMF", "WLZLF", "SSZLF",
				"MAF", "SSF", "KFF", "ZYZLF", "XYF", "KJYWF", "ZCYF", "ZCYF1", "XF", "BDBLZPF", "QDBLZPF", "NXYZLZPF",
				"XBYZLZPF", "HCYYCLF", "YYCLF", "YCXYYCLF", "QTF" };


		Map<String, Object> nationlityMap = getNationlityMap();

		Map<String, Object> deptMap = getDeptMap();

		List<Map<String, Object>> dataList = this.getExportDatas(list,nationlityMap,deptMap);
		list = null;
		ExcelUtil.exportExcel(out, headerArr, dataList);

		} catch (IOException e) {
			e.printStackTrace();
		}


	}

	public List<Map<String, Object>> getExportDatas(List<String> jsonList,Map<String,Object> nationlityMap,Map<String,Object> deptMap) {

		List<Map<String, Object>> dataList = new LinkedList<>();
		Map<String, Object> dataMap = null;
		int j=0;
		Map<String, Object> map =null;
		for (String string : jsonList) {
			//System.out.println(j++);
			 map = medicalRecordDataManageService.getMedicalRecordMapByGuid(string);

			if (MapUtils.isEmpty(map)) {
				continue;
			}
			dataMap = new LinkedHashMap<>();
			Map<String, Object> basicInfoMap = MapUtils.getMap(map, "basicInfo");
			Map<String, Object> cureInfoMap = MapUtils.getMap(map, "cureInfo");
			// 机构名称
			dataMap.put("USERNAME", "曲阜市人民医院");
			// 医疗付款方式
			dataMap.put("YLFKFS", MapUtils.getString(basicInfoMap, "medicalPayTypeCode"));
			// 健康卡号
			dataMap.put("JKKH", MapUtils.getString(basicInfoMap, "medicalHealthNumber"));
			// 住院次数
			dataMap.put("ZYCS", MapUtils.getString(basicInfoMap, "visitNumber"));
			// 病案号
			dataMap.put("BAH", MapUtils.getString(basicInfoMap, "mrId"));
			// 姓名
			dataMap.put("XM", MapUtils.getString(basicInfoMap, "patientName"));
			// 性别
			dataMap.put("XB", MapUtils.getString(basicInfoMap, "sexCode"));
			// 出生日期
			String birthday = MapUtils.getString(basicInfoMap, "birthday");
			if (StringUtils.isNotBlank(birthday) && !birthday.equals("null")) {
				dataMap.put("CSRQ", birthday.replaceAll("-", ""));
			} else {
				dataMap.put("CSRQ", null);
			}
			// 年龄
			if(StringUtils.isEmpty(MapUtils.getString(basicInfoMap, "yearOfAge"))) {
				dataMap.put("NL", 0);
			}else {
				dataMap.put("NL", MapUtils.getString(basicInfoMap, "yearOfAge"));
			}

			// 国籍
			String nationalityName = MapUtils.getString(basicInfoMap, "nationalityName");

			//System.out.println("国籍-------------------------:"+nationalityName);

			if(StringUtils.isEmpty(nationalityName)) {
				dataMap.put("GJ", "ZZZ");
			}else {
				String gj = MapUtils.getString(nationlityMap, nationalityName);
				if(StringUtils.isNotBlank(gj)) {
					dataMap.put("GJ", gj);
				}else {
					dataMap.put("GJ", "ZZZ");
				}
			}


			// (年龄不足1周岁的)年龄(月)
			Integer monthOfAge = ObjectUtils.getIntegerValue(basicInfoMap.get("monthOfAge"));
			Integer dayOfAge = ObjectUtils.getIntegerValue(basicInfoMap.get("dayOfAge"));
			String monthAgeStr = null;
			if(monthOfAge == null){
				if(dayOfAge!= null){
					float month = dayOfAge/30f;
					monthAgeStr = NumberUtils.getString(new BigDecimal(month), 2);

				}
			}else{
				monthAgeStr = ""+monthOfAge;
			}
			dataMap.put("BZYZSNL", monthAgeStr);
			//dataMap.put("BZYZSNL", MapUtils.getString(basicInfoMap, "monthOfAge"));
			if(cureInfoMap!= null){
				String babyBirthWeight = ObjectUtils.getStringValue(cureInfoMap.get("babyBirthWeight"));
				String babyInHospitalWeight = ObjectUtils.getStringValue(cureInfoMap.get("babyInHospitalWeight"));
				// 新生儿出生体重(克)
				dataMap.put("XSECSTZ", babyBirthWeight);
				// 新生儿入院体重(克）
				dataMap.put("XSERYTZ", babyInHospitalWeight);
			}else{
				// 新生儿出生体重(克)
				dataMap.put("XSECSTZ", null);
				// 新生儿入院体重(克）
				dataMap.put("XSERYTZ", null);
			}

			Map<String, Object> birthRegionalismMap = MapUtils.getMap(basicInfoMap, "birthRegionalism");
			if (MapUtils.isNotEmpty(birthRegionalismMap)) {

				// 出生地_省
				String provinceName =  MapUtils.getString(birthRegionalismMap, "provinceName");
				if(StringUtils.isNotBlank(provinceName)){
					dataMap.put("CSD_SG",medicalRecordDataManageService.getRegionCodeByName(provinceName) );
				}else{
					dataMap.put("CSD_SG", MapUtils.getString(birthRegionalismMap, "provinceCode"));
				}


				// 出生地—市
				String cityName =  MapUtils.getString(birthRegionalismMap, "cityName");
				if(StringUtils.isNotBlank(cityName)){
					dataMap.put("CSD_SI",medicalRecordDataManageService.getRegionCodeByName(cityName) );
				}else{
					dataMap.put("CSD_SI", MapUtils.getString(birthRegionalismMap, "cityCode"));
				}

				// 出生地—区县
				String countyName =  MapUtils.getString(birthRegionalismMap, "countyName");
				if(StringUtils.isNotBlank(countyName)){
					dataMap.put("CSD_QX",medicalRecordDataManageService.getRegionCodeByName(countyName) );
				}else{
					dataMap.put("CSD_QX", MapUtils.getString(birthRegionalismMap, "countyCode"));
				}

				// 出生地—详细地址
				dataMap.put("CSD_DZ", MapUtils.getString(birthRegionalismMap, "fullAddress"));
			} else {
				dataMap.put("CSD_SG", null);
				dataMap.put("CSD_SI", null);
				dataMap.put("CSD_QX", null);
				dataMap.put("CSD_DZ", null);
			}

			// 籍贯—省 籍贯—市
			Map<String, Object> nativePlaceRegionalismMap = MapUtils.getMap(basicInfoMap, "nativePlaceRegionalism");
			if (MapUtils.isNotEmpty(nativePlaceRegionalismMap)) {

				String provinceName =  MapUtils.getString(nativePlaceRegionalismMap, "provinceName");
				if(StringUtils.isNotBlank(provinceName)){
					dataMap.put("GG_SG",medicalRecordDataManageService.getRegionCodeByName(provinceName) );
				}else{
					dataMap.put("GG_SG", MapUtils.getString(nativePlaceRegionalismMap, "provinceCode"));
				}

				String cityName =  MapUtils.getString(nativePlaceRegionalismMap, "cityName");
				if(StringUtils.isNotBlank(cityName)){
					dataMap.put("GG_SI",medicalRecordDataManageService.getRegionCodeByName(cityName) );
				}else{
					dataMap.put("GG_SI", MapUtils.getString(nativePlaceRegionalismMap, "cityCode"));
				}


			} else {
				dataMap.put("GG_SG", null);
				dataMap.put("GG_SI", null);
			}
			// 民族
			dataMap.put("MZ", MapUtils.getString(basicInfoMap, "nationCode"));
			// 身份证件类别
			dataMap.put("SFZJLB", MapUtils.getString(basicInfoMap, "documentTypeCode"));
			// 身份证号
			String idNumber = ObjectUtils.getStringValue(basicInfoMap.get("idNumber"));
			/*if(idNumber!=null){
				if(idNumber.startsWith("000000")){
					idNumber = null;
				}
			}*/
			dataMap.put("SFZH", idNumber);
			//dataMap.put("SFZH", MapUtils.getString(basicInfoMap, "idNumber"));
			// 职业
			if(StringUtils.isEmpty(MapUtils.getString(basicInfoMap, "professionCode"))) {
				dataMap.put("ZY", "90");
			}else {
				dataMap.put("ZY", MapUtils.getString(basicInfoMap, "professionCode"));

			}

			// 婚姻
			dataMap.put("HY", MapUtils.getString(basicInfoMap, "marriageCode"));

			// 现住址
			Map<String, Object> permanentAddressRegionalismMap = MapUtils.getMap(basicInfoMap,
					"permanentAddressRegionalism");
			if (MapUtils.isNotEmpty(permanentAddressRegionalismMap)) {

				String provinceName =  MapUtils.getString(permanentAddressRegionalismMap, "provinceName");
				if(StringUtils.isNotBlank(provinceName)){
					dataMap.put("XZZ_SG",medicalRecordDataManageService.getRegionCodeByName(provinceName) );
				}else{
					dataMap.put("XZZ_SG", MapUtils.getString(permanentAddressRegionalismMap, "provinceCode"));
				}

				String cityName =  MapUtils.getString(permanentAddressRegionalismMap, "cityName");
				if(StringUtils.isNotBlank(cityName)){
					dataMap.put("XZZ_SI",medicalRecordDataManageService.getRegionCodeByName(cityName) );
				}else{
					dataMap.put("XZZ_SI", MapUtils.getString(permanentAddressRegionalismMap, "cityCode"));
				}

				String countyName =  MapUtils.getString(permanentAddressRegionalismMap, "countyName");
				if(StringUtils.isNotBlank(countyName)){
					dataMap.put("XZZ_QX",medicalRecordDataManageService.getRegionCodeByName(countyName) );
				}else{
					dataMap.put("XZZ_QX", MapUtils.getString(permanentAddressRegionalismMap, "countyCode"));
				}

				dataMap.put("XZZ_DZ", MapUtils.getString(permanentAddressRegionalismMap, "fullAddress"));
			} else {
				dataMap.put("XZZ_SG", null);
				dataMap.put("XZZ_SI", null);
				dataMap.put("XZZ_QX", null);
				dataMap.put("XZZ_DZ", null);
			}
			// 电话
			dataMap.put("DH", MapUtils.getString(basicInfoMap, "permanentAddressPhone"));
			// 邮编
			dataMap.put("YB1", MapUtils.getString(basicInfoMap, "permanentAddressPostCode"));

			// 户口地址
			Map<String, Object> registeredAddressRegionalismMap = MapUtils.getMap(basicInfoMap,
					"registeredAddressRegionalism");
			if (MapUtils.isNotEmpty(registeredAddressRegionalismMap)) {
				String provinceName =  MapUtils.getString(registeredAddressRegionalismMap, "provinceName");
				if(StringUtils.isNotBlank(provinceName)){
					dataMap.put("HKDZ_SG",medicalRecordDataManageService.getRegionCodeByName(provinceName) );
				}else{
					dataMap.put("HKDZ_SG", MapUtils.getString(registeredAddressRegionalismMap, "provinceCode"));
				}


				String cityName =  MapUtils.getString(registeredAddressRegionalismMap, "cityName");
				if(StringUtils.isNotBlank(cityName)){
					dataMap.put("HKDZ_SI",medicalRecordDataManageService.getRegionCodeByName(cityName) );
				}else{
					dataMap.put("HKDZ_SI", MapUtils.getString(registeredAddressRegionalismMap, "cityCode"));
				}

				String countyCode =  MapUtils.getString(registeredAddressRegionalismMap, "countyName");
				if(StringUtils.isNotBlank(countyCode)){
					dataMap.put("HKDZ_QX",medicalRecordDataManageService.getRegionCodeByName(countyCode) );
				}else{
					dataMap.put("HKDZ_QX", MapUtils.getString(registeredAddressRegionalismMap, "countyCode"));
				}


				dataMap.put("HKDZ_DZ", MapUtils.getString(registeredAddressRegionalismMap, "fullAddress"));
			} else {
				dataMap.put("HKDZ_SG", null);
				dataMap.put("HKDZ_SI", null);
				dataMap.put("HKDZ_QX", null);
				dataMap.put("HKDZ_DZ", null);
			}

			// 户口邮编
			dataMap.put("YB2", MapUtils.getString(basicInfoMap, "registeredAddressPostCode"));

			// 工作单位名称
			dataMap.put("GZDWJDZMC", MapUtils.getString(basicInfoMap, "workUnitName"));

			Map<String, Object> workUnitRegionalismMap = MapUtils.getMap(basicInfoMap, "workUnitRegionalism");
			if (MapUtils.isNotEmpty(workUnitRegionalismMap)) {

				String provinceName =  MapUtils.getString(workUnitRegionalismMap, "provinceName");
				if(StringUtils.isNotBlank(provinceName)){
					dataMap.put("GZDWJDZ_SG",medicalRecordDataManageService.getRegionCodeByName(provinceName) );
				}else{
					dataMap.put("GZDWJDZ_SG", MapUtils.getString(workUnitRegionalismMap, "provinceCode"));
				}


				String cityName =  MapUtils.getString(workUnitRegionalismMap, "cityName");
				if(StringUtils.isNotBlank(cityName)){
					dataMap.put("GZDWJDZ_SI",medicalRecordDataManageService.getRegionCodeByName(cityName) );
				}else{
					dataMap.put("GZDWJDZ_SI", MapUtils.getString(workUnitRegionalismMap, "cityCode"));
				}

				String countyCode =  MapUtils.getString(workUnitRegionalismMap, "countyName");
				if(StringUtils.isNotBlank(countyCode)){
					dataMap.put("GZDWJDZ_QX",medicalRecordDataManageService.getRegionCodeByName(countyCode) );
				}else{
					dataMap.put("GZDWJDZ_QX", MapUtils.getString(workUnitRegionalismMap, "countyCode"));
				}




				dataMap.put("GZDWJDZ_DZ", MapUtils.getString(workUnitRegionalismMap, "fullAddress"));
			} else {
				dataMap.put("GZDWJDZ_SG", null);
				dataMap.put("GZDWJDZ_SI", null);
				dataMap.put("GZDWJDZ_QX", null);
				dataMap.put("GZDWJDZ_DZ", null);
			}
			dataMap.put("DWDH", MapUtils.getString(basicInfoMap, "workUnitPhone"));
			dataMap.put("YB3", MapUtils.getString(basicInfoMap, "workUnitPostCode"));
			dataMap.put("LXRXM", MapUtils.getString(basicInfoMap, "linkManName"));

			dataMap.put("GX", MapUtils.getString(basicInfoMap, "linkManRelativeRelationCode"));

			Map<String, Object> linkManAddressRegionalismMap = MapUtils.getMap(basicInfoMap,
					"linkManAddressRegionalism");
			if (MapUtils.isNotEmpty(linkManAddressRegionalismMap)) {

				String provinceName =  MapUtils.getString(linkManAddressRegionalismMap, "provinceName");
				if(StringUtils.isNotBlank(provinceName)){
					dataMap.put("DZ_SG",medicalRecordDataManageService.getRegionCodeByName(provinceName) );
				}else{
					dataMap.put("DZ_SG", MapUtils.getString(linkManAddressRegionalismMap, "provinceCode"));
				}


				String cityName =  MapUtils.getString(linkManAddressRegionalismMap, "cityName");
				if(StringUtils.isNotBlank(cityName)){
					dataMap.put("DZ_SI",medicalRecordDataManageService.getRegionCodeByName(cityName) );
				}else{
					dataMap.put("DZ_SI", MapUtils.getString(linkManAddressRegionalismMap, "cityCode"));
				}

				String countyCode =  MapUtils.getString(linkManAddressRegionalismMap, "countyName");
				if(StringUtils.isNotBlank(countyCode)){
					dataMap.put("DZ_QX",medicalRecordDataManageService.getRegionCodeByName(countyCode) );
				}else{
					dataMap.put("DZ_QX", MapUtils.getString(linkManAddressRegionalismMap, "countyCode"));
				}

				dataMap.put("DZ_DZ", MapUtils.getString(linkManAddressRegionalismMap, "fullAddress"));
			} else {
				dataMap.put("DZ_SG", null);
				dataMap.put("DZ_SI", null);
				dataMap.put("DZ_QX", null);
				dataMap.put("DZ_DZ", null);
			}

			dataMap.put("DH2", MapUtils.getString(basicInfoMap, "linkManPhone"));

			dataMap.put("RYTJ", MapUtils.getString(basicInfoMap, "inHospitalTypeCode"));

			dataMap.put("ZZYLJGMC", null);

			String inTime = MapUtils.getString(basicInfoMap, "inHospitalDateTime");

			if (StringUtils.isNotBlank(inTime) && !"null".equals(inTime)) {
				String[] inTimeArr = inTime.split(" ");
				if (inTimeArr != null && inTimeArr.length > 0) {
					dataMap.put("RYSJ", inTimeArr[0].replaceAll("-", ""));
					if (inTimeArr.length == 2) {
						dataMap.put("RYSJS", inTimeArr[1].split(":")[0]);
					} else {
						dataMap.put("RYSJS", null);
					}

				} else {
					dataMap.put("RYSJ", null);
					dataMap.put("RYSJS", null);
				}
			} else {
				dataMap.put("RYSJ", null);
				dataMap.put("RYSJS", null);
			}

			String inDeptCode = MapUtils.getString(basicInfoMap, "inDeptCode");
			if(StringUtils.isEmpty(inDeptCode)) {
				dataMap.put("RYKB", null);
			}else {
				String deptCode = MapUtils.getString(deptMap,inDeptCode );
				if(StringUtils.isNotBlank(deptCode)) {
					dataMap.put("RYKB", deptCode);
				}else {
					dataMap.put("RYKB", null);
				}
			}

			String inHouseName = MapUtils.getString(basicInfoMap, "inHospitalHouseName");
			if(StringUtils.isEmpty(inHouseName)) {
				dataMap.put("RYBF", inDeptCode);
			}else {
				dataMap.put("RYBF", inHouseName.equals("-")?inDeptCode:inHouseName);
			}


			dataMap.put("ZKKB", null);
			dataMap.put("ZKKB1", null);
			dataMap.put("ZKKB2", null);

			String outTime = MapUtils.getString(basicInfoMap, "outHospitalDateTime");

			if (StringUtils.isNotBlank(outTime) && !"null".equals(outTime)) {
				String[] outTimeArr = outTime.split(" ");
				if (outTimeArr != null && outTimeArr.length > 0) {
					dataMap.put("CYSJ", outTimeArr[0].replaceAll("-", ""));
					if (outTimeArr.length == 2) {
						dataMap.put("CYSJS", outTimeArr[1].split(":")[0]);
					} else {
						dataMap.put("CYSJS", null);
					}

				} else {
					dataMap.put("CYSJ", null);
					dataMap.put("CYSJS", null);
				}
			} else {
				dataMap.put("CYSJ", null);
				dataMap.put("CYSJS", null);
			}

			String outDeptCode = MapUtils.getString(basicInfoMap, "outDeptCode");
			if(StringUtils.isEmpty(outDeptCode)) {
				dataMap.put("CYKB", null);
			}else {
				String deptCode = MapUtils.getString(deptMap,outDeptCode );
				if(StringUtils.isNotBlank(deptCode)) {
					dataMap.put("CYKB", deptCode);
				}else {
					dataMap.put("CYKB", null);
				}
			}

			String outHouseName = MapUtils.getString(basicInfoMap, "outHospitalHouseName");
			if(StringUtils.isEmpty(outHouseName)) {
				dataMap.put("CYBF", inDeptCode);
			}else {
				dataMap.put("CYBF", outHouseName.equals("-")?inDeptCode:outHouseName);
			}


			dataMap.put("SJZYTS", MapUtils.getString(basicInfoMap, "inHospitalDayNumber"));

			Map<String, Object> diseaseDiagInfoMap = MapUtils.getMap(map, "hqmsDiseaseDiagInfoMap");

			if (MapUtils.isNotEmpty(diseaseDiagInfoMap)) {
				Map<String, Object> outpatientDiagRecordMap = MapUtils.getMap(diseaseDiagInfoMap,
						"outpatientDiagRecord");
				if (MapUtils.isNotEmpty(outpatientDiagRecordMap)) {
					String outpatientDiagName = ObjectUtils.getStringValue(outpatientDiagRecordMap.get("diseaseDiagName"));
					String outpatientDiagCode = ObjectUtils.getStringValue(outpatientDiagRecordMap.get("diseaseDiagCode"));
					if(outpatientDiagCode==null){
						outpatientDiagCode = ObjectUtils.getStringValue(outpatientDiagRecordMap.get("diseaseDiagOriginalCode"));
					}
					if(outpatientDiagName==null){
						outpatientDiagName = ObjectUtils.getStringValue(outpatientDiagRecordMap.get("diseaseDiagOriginalDesc"));
					}
					if("无".equalsIgnoreCase(outpatientDiagName) || "-".equalsIgnoreCase(outpatientDiagName) ){
						outpatientDiagName = null;
					}
					if("无".equalsIgnoreCase(outpatientDiagCode) || "-".equalsIgnoreCase(outpatientDiagCode) ){
						outpatientDiagName = null;
					}
					dataMap.put("MZZD", outpatientDiagName);
					dataMap.put("JBBM", outpatientDiagCode);
					//dataMap.put("MZZD", MapUtils.getString(outpatientDiagRecordMap, "diseaseDiagName"));
					//dataMap.put("JBBM", MapUtils.getString(outpatientDiagRecordMap, "diseaseDiagCode"));
				} else {
					dataMap.put("MZZD", null);
					dataMap.put("JBBM", null);
				}

				Map<String, Object> mainDiagRecordMap = MapUtils.getMap(diseaseDiagInfoMap, "mainDiagRecord");
				if (MapUtils.isNotEmpty(mainDiagRecordMap)) {
					String mainDiagName = ObjectUtils.getStringValue(mainDiagRecordMap.get("diseaseDiagName"));
					String mainDiagCode = ObjectUtils.getStringValue(mainDiagRecordMap.get("diseaseDiagCode"));
					if(mainDiagCode==null){
						mainDiagCode = ObjectUtils.getStringValue(mainDiagRecordMap.get("diseaseDiagOriginalCode"));
					}
					if(mainDiagName==null){
						mainDiagName = ObjectUtils.getStringValue(mainDiagRecordMap.get("diseaseDiagOriginalDesc"));
					}
					if("无".equalsIgnoreCase(mainDiagName)||"-".equalsIgnoreCase(mainDiagName)){
						mainDiagName = null;
					}
					if("无".equalsIgnoreCase(mainDiagCode)||"-".equalsIgnoreCase(mainDiagCode)){
						mainDiagCode = null;
					}

					if(mainDiagCode!=null && (mainDiagCode.endsWith("?")|| mainDiagCode.endsWith("†"))) {
						mainDiagCode=mainDiagCode.replace("?", "+").replace("†", "+");
						List<Map<String,Object>> extraMainDiagMapList = (List<Map<String, Object>>) MapUtils.getObject(mainDiagRecordMap, "diseaseExtraDiagRecords");
						for (Map<String, Object> extraMainDiagMap : extraMainDiagMapList) {
							String diseaseExtraDiagCode = MapUtils.getString(extraMainDiagMap, "diseaseExtraDiagCode");
							if(StringUtils.isNotEmpty(diseaseExtraDiagCode) && diseaseExtraDiagCode.contains("*")) {
								mainDiagCode = mainDiagCode + diseaseExtraDiagCode;
							}
						}
					}

					dataMap.put("ZYZD", mainDiagName);
					dataMap.put("JBDM", mainDiagCode);
					//dataMap.put("ZYZD", MapUtils.getString(mainDiagRecordMap, "diseaseDiagName"));
					//dataMap.put("JBDM", MapUtils.getString(mainDiagRecordMap, "diseaseDiagCode"));
					String rybq =  MapUtils.getString(mainDiagRecordMap, "inHospitalDiseaseStateCode");
					if(StringUtils.isEmpty(rybq) && mainDiagCode!=null) {
						dataMap.put("RYBQ", "4");
					}else {
						dataMap.put("RYBQ", rybq);
					}

				} else {
					dataMap.put("ZYZD", null);
					dataMap.put("JBDM", null);
					dataMap.put("RYBQ", null);
				}

				// 其他诊断
				List<Map<String, Object>> diseaseDiagRecords = (List<Map<String, Object>>) MapUtils
						.getObject(diseaseDiagInfoMap, "diseaseDiagRecords");

				if (CollectionUtils.isNotEmpty(diseaseDiagRecords)) {
					int diagLength = diseaseDiagRecords.size();
					for (int i = 0; i < 15; i++) {

						if (diagLength > i) {
							Map<String, Object> otherDiagRecordMap = diseaseDiagRecords.get(i);
							String otherDiagName = ObjectUtils.getStringValue(otherDiagRecordMap.get("diseaseDiagName"));
							String otherDiagCode = ObjectUtils.getStringValue(otherDiagRecordMap.get("diseaseDiagCode"));
							if(otherDiagCode==null){
								otherDiagCode = ObjectUtils.getStringValue(otherDiagRecordMap.get("diseaseDiagOriginalCode"));
							}
							if(otherDiagName==null){
								otherDiagName = ObjectUtils.getStringValue(otherDiagRecordMap.get("diseaseDiagOriginalDesc"));
							}
							if("无".equalsIgnoreCase(otherDiagName)||"-".equalsIgnoreCase(otherDiagName)){
								otherDiagName = null;
							}
							if("无".equalsIgnoreCase(otherDiagCode)||"-".equalsIgnoreCase(otherDiagCode)){
								otherDiagCode = null;
							}

							if(StringUtils.isNotBlank(otherDiagCode) && (otherDiagCode.endsWith("?") || otherDiagCode.endsWith("†"))) {
								otherDiagCode = otherDiagCode.replace("?", "+").replace("†", "+");
								List<Map<String,Object>> otherExtraDiagRecords = (List<Map<String, Object>>) MapUtils.getObject(otherDiagRecordMap, "diseaseExtraDiagRecords");
								for (Map<String, Object> otherExtraDiagRecord : otherExtraDiagRecords) {
									String otherDiseaseExtraDiagCode = MapUtils.getString(otherExtraDiagRecord, "diseaseExtraDiagCode");

									if(StringUtils.isNotEmpty(otherDiseaseExtraDiagCode) && otherDiseaseExtraDiagCode.contains("*")) {
										otherDiagCode=otherDiagCode+otherDiseaseExtraDiagCode;
									}
								}

							}

							dataMap.put("QTZD" + (i + 1),otherDiagName);
							dataMap.put("JBDM" + (i + 1), otherDiagCode);

							//dataMap.put("QTZD" + (i + 1), MapUtils.getString(otherDiagRecordMap, "diseaseDiagName"));
							//dataMap.put("JBDM" + (i + 1), MapUtils.getString(otherDiagRecordMap, "diseaseDiagCode"));

							String rybq =  MapUtils.getString(otherDiagRecordMap, "inHospitalDiseaseStateCode");
							if(StringUtils.isEmpty(rybq) && otherDiagCode!=null) {
								dataMap.put("RYBQ" + (i + 1),
										"4");
							}else {
								dataMap.put("RYBQ" + (i + 1),
										rybq);
							}


						} else {
							dataMap.put("QTZD" + (i + 1), null);
							dataMap.put("JBDM" + (i + 1), null);
							dataMap.put("RYBQ" + (i + 1), null);
						}

					}
				} else {
					for (int i = 0; i < 15; i++) {

						dataMap.put("QTZD" + (i + 1), null);
						dataMap.put("JBDM" + (i + 1), null);
						dataMap.put("RYBQ" + (i + 1), null);
					}

				}
			}

			// 中毒的外部原因
			List<Map<String, Object>> damageAndVenenationDiagRecords = (List<Map<String, Object>>) MapUtils
					.getObject(diseaseDiagInfoMap, "damageAndVenenationDiagRecords");

			if (CollectionUtils.isNotEmpty(damageAndVenenationDiagRecords)) {
				Map<String, Object> damageAndVenenationDiagRecord = damageAndVenenationDiagRecords.get(0);
				String damageAndVenenationDiagName = ObjectUtils.getStringValue(damageAndVenenationDiagRecord.get("diseaseDiagName"));
				String damageAndVenenationDiagCode = ObjectUtils.getStringValue(damageAndVenenationDiagRecord.get("diseaseDiagCode"));
				if(damageAndVenenationDiagCode==null){
					damageAndVenenationDiagCode = ObjectUtils.getStringValue(damageAndVenenationDiagRecord.get("diseaseDiagOriginalCode"));
				}
				if(damageAndVenenationDiagName==null){
					damageAndVenenationDiagName = ObjectUtils.getStringValue(damageAndVenenationDiagRecord.get("diseaseDiagOriginalDesc"));
				}
				if("无".equalsIgnoreCase(damageAndVenenationDiagName)||"-".equalsIgnoreCase(damageAndVenenationDiagName)){
					damageAndVenenationDiagName = null;
				}
				if("无".equalsIgnoreCase(damageAndVenenationDiagCode) ||"-".equalsIgnoreCase(damageAndVenenationDiagCode)){
					damageAndVenenationDiagCode = null;
				}
				dataMap.put("WBYY", damageAndVenenationDiagName);
				dataMap.put("H23", damageAndVenenationDiagCode);
				//dataMap.put("WBYY", MapUtils.getString(damageAndVenenationDiagRecord, "diseaseDiagName"));
				//dataMap.put("H23", MapUtils.getString(damageAndVenenationDiagRecord, "diseaseDiagCode"));
			} else {
				dataMap.put("WBYY", null);
				dataMap.put("H23", null);
			}

			// 病理诊断

			List<Map<String, Object>> pathologyDiagRecords = (List<Map<String, Object>>) MapUtils
					.getObject(diseaseDiagInfoMap, "pathologyDiagRecords");
			if (CollectionUtils.isNotEmpty(pathologyDiagRecords)) {
				Map<String, Object> pathologyDiagRecord = pathologyDiagRecords.get(0);
				String pathologyDiagName = ObjectUtils.getStringValue(pathologyDiagRecord.get("diseaseDiagName"));
				String pathologyDiagCode = ObjectUtils.getStringValue(pathologyDiagRecord.get("diseaseDiagCode"));
				if(pathologyDiagCode==null){
					pathologyDiagCode = ObjectUtils.getStringValue(pathologyDiagRecord.get("diseaseDiagOriginalCode"));
				}
				if(pathologyDiagName==null){
					pathologyDiagName = ObjectUtils.getStringValue(pathologyDiagRecord.get("diseaseDiagOriginalDesc"));
				}
				if("无".equalsIgnoreCase(pathologyDiagName)||"-".equalsIgnoreCase(pathologyDiagName)){
					pathologyDiagName = null;
				}
				if("无".equalsIgnoreCase(pathologyDiagCode)||"-".equalsIgnoreCase(pathologyDiagCode)){
					pathologyDiagCode = null;
				}
				dataMap.put("BLZD", pathologyDiagName);
				dataMap.put("JBMM", pathologyDiagCode);

				//dataMap.put("BLZD", MapUtils.getString(pathologyDiagRecord, "diseaseDiagName"));
				//dataMap.put("JBMM", MapUtils.getString(pathologyDiagRecord, "diseaseDiagCode"));
				dataMap.put("BLH", MapUtils.getString(pathologyDiagRecord, "pathologyNumber"));

			} else {
				dataMap.put("BLZD", null);
				dataMap.put("JBMM", null);
				dataMap.put("BLH", null);
			}

			dataMap.put("ICDO3", null);



			dataMap.put("ZGZDYJ", MapUtils.getString(cureInfoMap, "malignantTumorHighestDiagBasisCode"));

			dataMap.put("YWGM", MapUtils.getString(basicInfoMap, "whetherDrugAllergyCode"));

			dataMap.put("GMYW", MapUtils.getString(basicInfoMap, "drugAllergyDesc"));
			String SWHZSJ = MapUtils.getString(basicInfoMap, "autopsyCode");
			if(SWHZSJ!=null){
				if(SWHZSJ.startsWith("-")){
					SWHZSJ = null;
				}
			}
			dataMap.put("SWHZSJ",SWHZSJ );

			dataMap.put("XX", MapUtils.getString(cureInfoMap, "bloodTypeCode"));

			Map<String, Object> nurseInfoMap = MapUtils.getMap(map, "nurseInfo");
			if (MapUtils.isNotEmpty(nurseInfoMap)) {
				dataMap.put("TJHL_T", MapUtils.getString(nurseInfoMap, "specialNurseDayNumber"));
				dataMap.put("YJHL_T", MapUtils.getString(nurseInfoMap, "firstLevelNurseDayNumber"));
				dataMap.put("EJHL_T", MapUtils.getString(nurseInfoMap, "secondLevelNurseDayNumber"));
				dataMap.put("SJHL_T", MapUtils.getString(nurseInfoMap, "threeLevelNurseDayNumber"));
			} else {
				dataMap.put("TJHL_T", null);
				dataMap.put("YJHL_T", null);
				dataMap.put("EJHL_T", null);
				dataMap.put("SJHL_T", null);
			}

			dataMap.put("RH", MapUtils.getString(cureInfoMap, "rhBloodTypeCode"));

			List<Map<String, Object>> medicalWorks = (List<Map<String, Object>>) MapUtils.getObject(cureInfoMap,
					"cureWorkers");

			if (CollectionUtils.isNotEmpty(medicalWorks)) {
				// KZR
				int kzrCount =0;
				for (Map<String, Object> medicalWork : medicalWorks) {
					String professionTitleCode = MapUtils.getString(medicalWork, "professionTitleCode");
					if ("A1001".equals(professionTitleCode)) {
						kzrCount++;
						dataMap.put("KZR", MapUtils.getString(medicalWork, "medicalWorkerName"));
					}

					if(kzrCount==0) {
						dataMap.put("KZR", null);
					}

				}

				// YLZZ
				int ylzzCount =0;
				for (Map<String, Object> medicalWork : medicalWorks) {
					String professionTitleCode = MapUtils.getString(medicalWork, "professionTitleCode");
					if ("A1003".equals(professionTitleCode)) {
						ylzzCount++;
						dataMap.put("YLZZ", MapUtils.getString(medicalWork, "medicalWorkerName"));
					}

					if(ylzzCount==0) {
						dataMap.put("YLZZ", null);
					}

				}

				// ZRYS
				int zrysCount =0;
				for (Map<String, Object> medicalWork : medicalWorks) {
					String professionTitleCode = MapUtils.getString(medicalWork, "professionTitleCode");
					if ("A2001".equals(professionTitleCode)) {
						zrysCount++;
						dataMap.put("ZRYS", MapUtils.getString(medicalWork, "medicalWorkerName"));
					}

					if(zrysCount==0) {
						dataMap.put("ZRYS", null);
					}

				}

				// ZZYS
				int zzysCount =0;
				for (Map<String, Object> medicalWork : medicalWorks) {
					String professionTitleCode = MapUtils.getString(medicalWork, "professionTitleCode");
					if ("A2003".equals(professionTitleCode)) {
						dataMap.put("ZZYS", MapUtils.getString(medicalWork, "medicalWorkerName"));
					}

					if(zzysCount==0) {
						dataMap.put("ZZYS", null);
					}


				}

				// ZYYS
				int zyysCount =0;
				for (Map<String, Object> medicalWork : medicalWorks) {
					String professionTitleCode = MapUtils.getString(medicalWork, "professionTitleCode");
					if ("A2005".equals(professionTitleCode)) {
						zyysCount++;
						dataMap.put("ZYYS", MapUtils.getString(medicalWork, "medicalWorkerName"));
					}

					if(zyysCount==0) {
						dataMap.put("ZYYS", null);
					}

				}

				// ZRHS
				int zrhsCount =0;
				for (Map<String, Object> medicalWork : medicalWorks) {
					String professionTitleCode = MapUtils.getString(medicalWork, "professionTitleCode");
					if ("A3001".equals(professionTitleCode)) {
						zrhsCount++;
						dataMap.put("ZRHS", MapUtils.getString(medicalWork, "medicalWorkerName"));
					}

					if(zrhsCount==0) {
						dataMap.put("ZRHS", null);
					}

				}

				// JXYS
				int jxysCount = 0;
				for (Map<String, Object> medicalWork : medicalWorks) {
					String professionTitleCode = MapUtils.getString(medicalWork, "professionTitleCode");
					if ("A2006".equals(professionTitleCode)) {
						jxysCount++;
						dataMap.put("JXYS", MapUtils.getString(medicalWork, "medicalWorkerName"));
					}

					if(jxysCount==0) {
						dataMap.put("JXYS", null);
					}

				}

				// SXYS
				int sxysCount = 0;
				for (Map<String, Object> medicalWork : medicalWorks) {
					String professionTitleCode = MapUtils.getString(medicalWork, "professionTitleCode");
					if ("A2008".equals(professionTitleCode)) {
						sxysCount++;
						dataMap.put("SXYS", MapUtils.getString(medicalWork, "medicalWorkerName"));
					}
					if(sxysCount==0) {
						dataMap.put("SXYS", null);
					}

				}

				// BMY
				int bmyCount = 0;
				for (Map<String, Object> medicalWork : medicalWorks) {
					String professionTitleCode = MapUtils.getString(medicalWork, "professionTitleCode");
					if ("A4001".equals(professionTitleCode)) {
						bmyCount++;
						dataMap.put("BMY", MapUtils.getString(medicalWork, "medicalWorkerName"));
					}

					if(bmyCount==0) {
						dataMap.put("BMY", null);
					}

				}

			} else {
				dataMap.put("KZR", null);
				dataMap.put("YLZZ", null);
				dataMap.put("ZRYS", null);
				dataMap.put("ZZYS", null);
				dataMap.put("ZYYS", null);
				dataMap.put("ZRHS", null);

				dataMap.put("JXYS", null);
				dataMap.put("SXYS", null);
				dataMap.put("BMY", null);
			}

			String qualityCode = MapUtils.getString(cureInfoMap, "medicalRecordQualityCode");
			if(StringUtils.isEmpty(qualityCode)) {
				dataMap.put("BAZL", "1");
			}else {
				dataMap.put("BAZL", MapUtils.getString(cureInfoMap, "medicalRecordQualityCode"));

			}

			if (CollectionUtils.isNotEmpty(medicalWorks)) {
				// ZKYS
				int zkysCount =0;
				for (Map<String, Object> medicalWork : medicalWorks) {
					String professionTitleCode = MapUtils.getString(medicalWork, "professionTitleCode");
					if ("A2009".equals(professionTitleCode)) {
						zkysCount++;
						dataMap.put("ZKYS", MapUtils.getString(medicalWork, "medicalWorkerName"));
					}

					if(zkysCount==0) {
						dataMap.put("ZKYS", null);
					}



				}

				// ZKHS
				int zkhsCount = 0;
				for (Map<String, Object> medicalWork : medicalWorks) {
					String professionTitleCode = MapUtils.getString(medicalWork, "professionTitleCode");
					if ("A3003".equals(professionTitleCode)) {
						dataMap.put("ZKHS", MapUtils.getString(medicalWork, "medicalWorkerName"));
					}

					if(zkhsCount==0) {
						dataMap.put("ZKHS", null);
					}

				}
			} else {
				dataMap.put("ZKYS", null);
				dataMap.put("ZKHS", null);
			}

			String qualityTime = MapUtils.getString(cureInfoMap, "qualityControlDateTime");

			if (StringUtils.isNotBlank(qualityTime) && !"null".equals(qualityTime)) {
				String[] qualityTimeArr = qualityTime.split(" ");
				if (qualityTimeArr != null && qualityTimeArr.length > 0) {
					dataMap.put("ZKRQ", qualityTimeArr[0].replaceAll("-", ""));

				} else {
					dataMap.put("ZKRQ", null);
				}
			} else {
				dataMap.put("ZKRQ", null);
			}

			Map<String, Object> operationInfoMap = MapUtils.getMap(map, "hqmsOperateInfo");

			if (MapUtils.isNotEmpty(operationInfoMap)) {
				List<Map<String, Object>> operateRecords = (List<Map<String, Object>>) MapUtils
						.getObject(operationInfoMap, "operateRecords");
				if (CollectionUtils.isNotEmpty(operateRecords)) {
					List<Map<String, Object>> extraOperateRecords = new ArrayList<Map<String,Object>>();
					int i = 0;
					for(Map<String, Object> operateRecord : operateRecords ){
						if(i==8){
							break;
						}
						List<Map<String, Object>> operateExtraRecords = (List<Map<String, Object>>)operateRecord.get("operateExtraRecords");
						if(operateExtraRecords != null && operateExtraRecords.size()> 0){
							extraOperateRecords.add(operateRecord);
						}
						String operateCode = ObjectUtils.getStringValue(operateRecord.get("operateCode"));
						if("无".equalsIgnoreCase(operateCode)||"-".equalsIgnoreCase(operateCode)){
							operateCode = null;
						}
						dataMap.put("SSJCZBM" + (i + 1),operateCode);
						//dataMap.put("SSJCZBM" + (i + 1), MapUtils.getString(operateRecord, "operateCode"));

						String operateTime = MapUtils.getString(operateRecord, "operateStartDate");
						if (operateTime!= null && StringUtils.isNotBlank(operateTime) && !"null".equals(operateTime)) {
							String[] operateTimeArr = operateTime.split(" ");
							if (operateTimeArr != null && operateTimeArr.length > 0) {
								dataMap.put("SSJCZRQ" + (i + 1), operateTimeArr[0].replaceAll("-", ""));

							} else {
								dataMap.put("SSJCZRQ" + (i + 1), null);
							}
						} else {
							dataMap.put("SSJCZRQ" + (i + 1), null);
						}

						dataMap.put("SSJB" + (i + 1), MapUtils.getString(operateRecord, "opsLevelCode"));
						dataMap.put("SSLX" + (i + 1),  MapUtils.getString(operateRecord, "patientSourceCode"));
						String operateName = ObjectUtils.getStringValue(operateRecord.get("operateName"));
						if("无".equalsIgnoreCase(operateCode)||"-".equalsIgnoreCase(operateName)){
							operateName = null;
						}

						dataMap.put("SSJCZMC" + (i + 1), operateName);

						//dataMap.put("SSJCZMC" + (i + 1), MapUtils.getString(operateRecord, "operateName"));

						List<Map<String, Object>> operateWorkers = (List<Map<String, Object>>) MapUtils
								.getObject(operateRecord, "operateWorkers");
						if (CollectionUtils.isNotEmpty(operateWorkers)) {

							for (Map<String, Object> operateWorker : operateWorkers) {
								String professionTitleCode = MapUtils.getString(operateWorker,
										"professionTitleCode");
								if ("A5001".equals(professionTitleCode)) {
									dataMap.put("SZ" + (i + 1),
											MapUtils.getString(operateWorker, "medicalWorkerName"));
								}
							}

							for (Map<String, Object> operateWorker : operateWorkers) {
								String professionTitleCode = MapUtils.getString(operateWorker,
										"professionTitleCode");
								/*if ("21804".equals(professionTitleCode)) {
									dataMap.put("YZ" + (i + 1),
											MapUtils.getString(operateWorker, "medicalWorkerName"));
								}*/
								if ("A5003".equals(professionTitleCode)) {
									dataMap.put("YZ" + (i + 1),
											MapUtils.getString(operateWorker, "medicalWorkerName"));
								}
							}

							for (Map<String, Object> operateWorker : operateWorkers) {
								String professionTitleCode = MapUtils.getString(operateWorker,
										"professionTitleCode");
								/*if ("20708".equals(professionTitleCode)) {
									dataMap.put("EZ" + (i + 1),
											MapUtils.getString(operateWorker, "medicalWorkerName"));
								}*/
								if ("A5004".equals(professionTitleCode)) {
									dataMap.put("EZ" + (i + 1),
											MapUtils.getString(operateWorker, "medicalWorkerName"));
								}
							}

						} else {
							dataMap.put("SZ" + (i + 1), null);
							dataMap.put("YZ" + (i + 1), null);
							dataMap.put("EZ" + (i + 1), null);
						}
						String incisionLevelCode = MapUtils.getString(operateRecord, "incisionLevelCode");
						if(StringUtils.isNotBlank(incisionLevelCode)){
							try {
								if("0".equals(incisionLevelCode)){
									 dataMap.put("QKDJ" + (i + 1), "1");
								}else if("4".equals(incisionLevelCode)){
									 dataMap.put("QKDJ" + (i + 1), "1");
								}else{
									 int rkdjNum = Integer.parseInt(incisionLevelCode)+1;
									 dataMap.put("QKDJ" + (i + 1), rkdjNum+"");
								}
							} catch (Exception e) {
								e.printStackTrace();
								dataMap.put("QKDJ" + (i + 1),null);
							}
						}else{
							dataMap.put("QKDJ" + (i + 1),null);
						}

						String cicatrizeTypeCode =  MapUtils.getString(operateRecord, "cicatrizeTypeCode");
						if(StringUtils.isEmpty(cicatrizeTypeCode)){
							dataMap.put("QKYHLB" + (i + 1), null);
						}else{
							if("-".equals(cicatrizeTypeCode)){
								dataMap.put("QKYHLB" + (i + 1), null);
							}
							if("5".equals(cicatrizeTypeCode) || "5.0".equals(cicatrizeTypeCode)){
								dataMap.put("QKYHLB" + (i + 1), null);
							}else{
								dataMap.put("QKYHLB" + (i + 1), Integer.parseInt(cicatrizeTypeCode)+"");
							}

						}

						dataMap.put("MZFS" + (i + 1), MapUtils.getString(operateRecord, "anaesthesiaTypeCode"));

						if (CollectionUtils.isNotEmpty(operateWorkers)) {

							for (Map<String, Object> operateWorker : operateWorkers) {
								String professionTitleCode = MapUtils.getString(operateWorker,
										"professionTitleCode");
								if ("A5002".equals(professionTitleCode)) {
									dataMap.put("MZYS" + (i + 1),
											MapUtils.getString(operateWorker, "medicalWorkerName"));
								}
							}
						} else {
							dataMap.put("MZYS" + (i + 1), null);
						}


						i++;
					}
					for(Map<String, Object> operateRecord : extraOperateRecords ){
						if(i==8){
							break;
						}
						List<Map<String, Object>> operateExtraRecords = (List<Map<String, Object>>)operateRecord.get("operateExtraRecords");
						for(Map<String, Object> operateExtraRecord : operateExtraRecords ){
							if(i==8){
								break;
							}
							String operateCode = ObjectUtils.getStringValue(operateExtraRecord.get("operateExtraCode"));
							if("无".equalsIgnoreCase(operateCode)||"-".equalsIgnoreCase(operateCode)){
								operateCode = null;
							}
							String operateName = ObjectUtils.getStringValue(operateExtraRecord.get("operateExtraName"));
							if("无".equalsIgnoreCase(operateCode)||"-".equalsIgnoreCase(operateName)){
								operateName = null;
							}
							if(operateCode==null && operateName==null){
								continue;
							}


							dataMap.put("SSJCZBM" + (i + 1),operateCode);

							String operateTime = MapUtils.getString(operateRecord, "operateStartDate");
							if (StringUtils.isNotBlank(operateTime) && !"null".equals(operateTime)) {
								String[] operateTimeArr = operateTime.split(" ");
								if (operateTimeArr != null && operateTimeArr.length > 0) {
									dataMap.put("SSJCZRQ" + (i + 1), operateTimeArr[0].replaceAll("-", ""));

								} else {
									dataMap.put("SSJCZRQ" + (i + 1), null);
								}
							} else {
								dataMap.put("SSJCZRQ" + (i + 1), null);
							}

							dataMap.put("SSJB" + (i + 1), MapUtils.getString(operateRecord, "opsLevelCode"));
							dataMap.put("SSLX" + (i + 1),  MapUtils.getString(operateRecord, "patientSourceCode"));

							dataMap.put("SSJCZMC" + (i + 1), operateName);

							//dataMap.put("SSJCZMC" + (i + 1), MapUtils.getString(operateRecord, "operateName"));

							List<Map<String, Object>> operateWorkers = (List<Map<String, Object>>) MapUtils
									.getObject(operateRecord, "operateWorkers");
							if (CollectionUtils.isNotEmpty(operateWorkers)) {

								for (Map<String, Object> operateWorker : operateWorkers) {
									String professionTitleCode = MapUtils.getString(operateWorker,
											"professionTitleCode");
									if ("A5001".equals(professionTitleCode)) {
										dataMap.put("SZ" + (i + 1),
												MapUtils.getString(operateWorker, "medicalWorkerName"));
									}
								}

								for (Map<String, Object> operateWorker : operateWorkers) {
									String professionTitleCode = MapUtils.getString(operateWorker,
											"professionTitleCode");
									if ("A5003".equals(professionTitleCode)) {
										dataMap.put("YZ" + (i + 1),
												MapUtils.getString(operateWorker, "medicalWorkerName"));
									}
								}

								for (Map<String, Object> operateWorker : operateWorkers) {
									String professionTitleCode = MapUtils.getString(operateWorker,
											"professionTitleCode");
									if ("A5004".equals(professionTitleCode)) {
										dataMap.put("EZ" + (i + 1),
												MapUtils.getString(operateWorker, "medicalWorkerName"));
									}
								}

							} else {
								dataMap.put("SZ" + (i + 1), null);
								dataMap.put("YZ" + (i + 1), null);
								dataMap.put("EZ" + (i + 1), null);
							}

							String QKDJ = MapUtils.getString(operateRecord, "incisionLevelCode");
							if(StringUtils.isNotBlank(QKDJ)){
								try {
									if("0".equals(QKDJ)){
										 dataMap.put("QKDJ" + (i + 1), "1");
									}else if("4".equals(QKDJ)){
										 dataMap.put("QKDJ" + (i + 1), "1");
									}else{
										 int rkdjNum = Integer.parseInt(QKDJ);
										 dataMap.put("QKDJ" + (i + 1), rkdjNum+++"");
									}

								} catch (Exception e) {
									e.printStackTrace();
									dataMap.put("QKDJ" + (i + 1), null);
								}
							}else{
								dataMap.put("QKDJ" + (i + 1), null);

							}


							String cicatrizeTypeCode =  MapUtils.getString(operateRecord, "cicatrizeTypeCode");
							if(StringUtils.isNotEmpty(cicatrizeTypeCode)){
								if("-".equals(cicatrizeTypeCode)){
									dataMap.put("QKYHLB" + (i + 1), null);
								}else
								if("5".equals(cicatrizeTypeCode) || "5.0".equals(cicatrizeTypeCode)){
									dataMap.put("QKYHLB" + (i + 1), null);
								}else{
									dataMap.put("QKYHLB" + (i + 1), Integer.parseInt(cicatrizeTypeCode)+"");
								}

							}else{
								dataMap.put("QKYHLB" + (i + 1), null);
							}

							dataMap.put("MZFS" + (i + 1), MapUtils.getString(operateRecord, "anaesthesiaTypeCode"));

							if (CollectionUtils.isNotEmpty(operateWorkers)) {

								for (Map<String, Object> operateWorker : operateWorkers) {
									String professionTitleCode = MapUtils.getString(operateWorker,
											"professionTitleCode");
									if ("A5002".equals(professionTitleCode)) {
										dataMap.put("MZYS" + (i + 1),
												MapUtils.getString(operateWorker, "medicalWorkerName"));
									}
								}
							} else {
								dataMap.put("MZYS" + (i + 1), null);
							}


							i++;
						}


					}


					/*for (int i = 0; i < 8; i++) {
						if (operateLength < i) {
							Map<String, Object> operateRecord = operateRecords.get(i);
							dataMap.put("SSJCZBM" + (i + 1), MapUtils.getString(operateRecord, "operateCode"));

							String operateTime = MapUtils.getString(operateRecord, "operateStartDate");
							if (StringUtils.isNotBlank(operateTime) && !"null".equals(operateTime)) {
								String[] operateTimeArr = qualityTime.split(" ");
								if (operateTimeArr != null && operateTimeArr.length > 0) {
									dataMap.put("SSJCZRQ" + (i + 1), operateTimeArr[0].replaceAll("-", ""));

								} else {
									dataMap.put("SSJCZRQ" + (i + 1), null);
								}
							} else {
								dataMap.put("SSJCZRQ" + (i + 1), null);
							}

							dataMap.put("SSJB" + (i + 1), MapUtils.getString(operateRecord, "incisionLevelCode"));
							dataMap.put("SSLX" + (i + 1), null);

							dataMap.put("SSJCZMC" + (i + 1), MapUtils.getString(operateRecord, "operateName"));

							dataMap.put("SSJCZMC" + (i + 1), MapUtils.getString(operateRecord, "operateName"));

							List<Map<String, Object>> operateWorkers = (List<Map<String, Object>>) MapUtils
									.getObject(operateRecord, "operateWorkers");
							if (CollectionUtils.isNotEmpty(operateWorkers)) {

								for (Map<String, Object> operateWorker : operateWorkers) {
									String professionTitleCode = MapUtils.getString(operateWorker,
											"professionTitleCode");
									if ("A5001".equals(professionTitleCode)) {
										dataMap.put("SZ" + (i + 1),
												MapUtils.getString(operateWorker, "medicalWorkerName"));
									}
								}

								for (Map<String, Object> operateWorker : operateWorkers) {
									String professionTitleCode = MapUtils.getString(operateWorker,
											"professionTitleCode");
									if ("21804".equals(professionTitleCode)) {
										dataMap.put("YZ" + (i + 1),
												MapUtils.getString(operateWorker, "medicalWorkerName"));
									}
								}

								for (Map<String, Object> operateWorker : operateWorkers) {
									String professionTitleCode = MapUtils.getString(operateWorker,
											"professionTitleCode");
									if ("20708".equals(professionTitleCode)) {
										dataMap.put("EZ" + (i + 1),
												MapUtils.getString(operateWorker, "medicalWorkerName"));
									}
								}

							} else {
								dataMap.put("SZ" + (i + 1), null);
								dataMap.put("YZ" + (i + 1), null);
								dataMap.put("EZ" + (i + 1), null);
							}

							dataMap.put("QKDJ" + (i + 1), MapUtils.getString(operateRecord, "incisionLevelCode"));
							dataMap.put("QKYHLB" + (i + 1), MapUtils.getString(operateRecord, "cicatrizeTypeCode"));
							dataMap.put("MZFS" + (i + 1), MapUtils.getString(operateRecord, "anaesthesiaTypeCode"));

							if (CollectionUtils.isNotEmpty(operateWorkers)) {

								for (Map<String, Object> operateWorker : operateWorkers) {
									String professionTitleCode = MapUtils.getString(operateWorker,
											"professionTitleCode");
									if ("A5002".equals(professionTitleCode)) {
										dataMap.put("MZYS" + (i + 1),
												MapUtils.getString(operateWorker, "medicalWorkerName"));
									}
								}
							} else {
								dataMap.put("MZYS" + (i + 1), null);
							}

						} else {
							dataMap.put("SSJCZBM" + (i + 1), null);
							dataMap.put("SSJCZRQ" + (i + 1), null);
							dataMap.put("SSJB" + (i + 1), null);
							dataMap.put("SSLX" + (i + 1), null);
							dataMap.put("SSJCZMC" + (i + 1), null);
							dataMap.put("SZ" + (i + 1), null);
							dataMap.put("YZ" + (i + 1), null);
							dataMap.put("EZ" + (i + 1), null);
							dataMap.put("QKDJ" + (i + 1), null);
							dataMap.put("QKYHLB" + (i + 1), null);
							dataMap.put("MZFS" + (i + 1), null);
							dataMap.put("MZYS" + (i + 1), null);
						}

					}*/
				} else {
					for (int i = 0; i < 8; i++) {
						dataMap.put("SSJCZBM" + (i + 1), null);
						dataMap.put("SSJCZRQ" + (i + 1), null);
						dataMap.put("SSJB" + (i + 1), null);
						dataMap.put("SSLX" + (i + 1), null);
						dataMap.put("SSJCZMC" + (i + 1), null);
						dataMap.put("SZ" + (i + 1), null);
						dataMap.put("YZ" + (i + 1), null);
						dataMap.put("EZ" + (i + 1), null);
						dataMap.put("QKDJ" + (i + 1), null);
						dataMap.put("QKYHLB" + (i + 1), null);
						dataMap.put("MZFS" + (i + 1), null);
						dataMap.put("MZYS" + (i + 1), null);

					}
				}

			} else {
				for (int i = 0; i < 8; i++) {
					dataMap.put("SSJCZBM" + (i + 1), null);
					dataMap.put("SSJCZRQ" + (i + 1), null);
					dataMap.put("SSJB" + (i + 1), null);
					dataMap.put("SSLX" + (i + 1), null);
					dataMap.put("SSJCZMC" + (i + 1), null);
					dataMap.put("SZ" + (i + 1), null);
					dataMap.put("YZ" + (i + 1), null);
					dataMap.put("EZ" + (i + 1), null);
					dataMap.put("QKDJ" + (i + 1), null);
					dataMap.put("QKYHLB" + (i + 1), null);
					dataMap.put("MZFS" + (i + 1), null);
					dataMap.put("MZYS" + (i + 1), null);

				}
			}
			dataMap.put("RJQK", ObjectUtils.getStringValue(cureInfoMap.get("whetherEnterClinicalPathsCode")));
			dataMap.put("WCQK", ObjectUtils.getStringValue(cureInfoMap.get("whetherFinishClinicalPathsCode")));
			dataMap.put("BYQK", ObjectUtils.getStringValue(cureInfoMap.get("whetherConditionVariationCode")));
			/*dataMap.put("RJQK", MapUtils.getString(cureInfoMap, "whetherEnterClinicalPathsCode"));
			dataMap.put("WCQK", MapUtils.getString(cureInfoMap, "whetherFinishClinicalPathsCode"));
			dataMap.put("BYQK", MapUtils.getString(cureInfoMap, "whetherConditionVariationCode"));*/

			dataMap.put("LYFS", MapUtils.getString(basicInfoMap, "outHospitalTypeCode"));

			dataMap.put("YZZY_YLJG", MapUtils.getString(basicInfoMap, "receiveUnitName"));

			dataMap.put("WSY_YLJG", null);

			String rehospitalAimOf31Code = MapUtils.getString(cureInfoMap, "rehospitalAimOf31Code");
			if(StringUtils.isEmpty(rehospitalAimOf31Code)) {
				dataMap.put("SFZZYJH", "1");
			}else {
				dataMap.put("SFZZYJH", MapUtils.getString(cureInfoMap, "rehospitalAimOf31Code"));
			}


			dataMap.put("MD", MapUtils.getString(cureInfoMap, "rehospitalAimOf31Description"));

			dataMap.put("RYQ_T", MapUtils.getString(cureInfoMap, "dayOfBeforeInHospitalComa"));

			dataMap.put("RYQ_XS", MapUtils.getString(cureInfoMap, "hourOfBeforeInHospitalComa"));

			dataMap.put("RYQ_F", MapUtils.getString(cureInfoMap, "minuteOfBeforeInHospitalComa"));

			dataMap.put("RYH_T", MapUtils.getString(cureInfoMap, "dayOfAfterInHospitalComa"));

			dataMap.put("RYH_XS", MapUtils.getString(cureInfoMap, "hourOfAfterInHospitalComa"));

			dataMap.put("RYH_F", MapUtils.getString(cureInfoMap, "minuteOfAfterInHospitalComa"));

			Map<String, Object> costInfoMap = MapUtils.getMap(map, "costInfo");
			if (MapUtils.isNotEmpty(costInfoMap)) {
				String ZFY = ObjectUtils.getStringValue(costInfoMap.get("totalCost"));
				if(ZFY!=null){
					dataMap.put("ZFY", ZFY);
				}else{
					dataMap.put("ZFY", "0");
				}
				String ZFJE = ObjectUtils.getStringValue(costInfoMap.get("selfCost"));
				//String ZFJE = MapUtils.getString(costInfoMap, "selfCost");
				if(ZFJE!=null){
					dataMap.put("ZFJE", ZFJE);
				}else{
					dataMap.put("ZFJE", "0");
				}

				//dataMap.put("ZFJE", MapUtils.getString(costInfoMap, "selfCost"));

				List<Map<String, Object>> costRecords = (List<Map<String, Object>>) MapUtils.getObject(costInfoMap,
						"costRecords");
				if (CollectionUtils.isNotEmpty(costRecords)) {

					int ylfwfCount = 0;
					for (Map<String, Object> costRecord : costRecords) {

						String medicalCostTypeCode = MapUtils.getString(costRecord, "medicalCostTypeCode");
						if ("C01001".equals(medicalCostTypeCode)) {
							ylfwfCount++;
							String money = MapUtils.getString(costRecord, "costMoney");
							if(money == null){
								dataMap.put("YLFUF","0");
							}else{
								dataMap.put("YLFUF",money);
							}
							//dataMap.put("YLFUF", MapUtils.getString(costRecord, "costMoney"));
						}

					}

					if(ylfwfCount==0) {
						dataMap.put("YLFUF","0");
					}
					//
					int zlczfCount =0;
					for (Map<String, Object> costRecord : costRecords) {
						String medicalCostTypeCode = MapUtils.getString(costRecord, "medicalCostTypeCode");
						if ("C01002".equals(medicalCostTypeCode)) {
							zlczfCount++;
							String money = MapUtils.getString(costRecord, "costMoney");
							if(money == null){
								dataMap.put("ZLCZF","0");
							}else{
								dataMap.put("ZLCZF",money);
							}
							//dataMap.put("ZLCZF", MapUtils.getString(costRecord, "costMoney"));
						}
					}

					if(zlczfCount==0) {
						dataMap.put("ZLCZF","0");
					}

					//
					int hlfCount =0;
					for (Map<String, Object> costRecord : costRecords) {
						String medicalCostTypeCode = MapUtils.getString(costRecord, "medicalCostTypeCode");
						if ("C01003".equals(medicalCostTypeCode)) {
							hlfCount++;
							String money = MapUtils.getString(costRecord, "costMoney");
							if(money == null){
								dataMap.put("HLF","0");
							}else{
								dataMap.put("HLF",money);
							}
							//dataMap.put("HLF", MapUtils.getString(costRecord, "costMoney"));
						}
					}

					if(hlfCount==0) {
						dataMap.put("HLF","0");
					}

					int qtfyCount = 0;
					for (Map<String, Object> costRecord : costRecords) {
						String medicalCostTypeCode = MapUtils.getString(costRecord, "medicalCostTypeCode");
						if ("C01999".equals(medicalCostTypeCode)) {
							qtfyCount++;
							String money = MapUtils.getString(costRecord, "costMoney");
							if(money == null){
								dataMap.put("QTFY","0");
							}else{
								dataMap.put("QTFY",money);
							}
							//dataMap.put("QTFY", MapUtils.getString(costRecord, "costMoney"));
						}
					}

					if(qtfyCount==0) {
						dataMap.put("QTFY","0");
					}

					// (5)病理诊断费
					int blzdfCount = 0;
					for (Map<String, Object> costRecord : costRecords) {
						String medicalCostTypeCode = MapUtils.getString(costRecord, "medicalCostTypeCode");
						if ("C02001".equals(medicalCostTypeCode)) {
							blzdfCount++;
							String money = MapUtils.getString(costRecord, "costMoney");
							if(money == null){
								dataMap.put("BLZDF","0");
							}else{
								dataMap.put("BLZDF",money);
							}
							//dataMap.put("BLZDF", MapUtils.getString(costRecord, "costMoney"));
						}
					}

					if(blzdfCount==0) {
						dataMap.put("BLZDF","0");
					}


					// 实验室诊断费
					int syszdfCount = 0;
					for (Map<String, Object> costRecord : costRecords) {
						String medicalCostTypeCode = MapUtils.getString(costRecord, "medicalCostTypeCode");
						if ("C02002".equals(medicalCostTypeCode)) {
							syszdfCount++;
							String money = MapUtils.getString(costRecord, "costMoney");
							if(money == null){
								dataMap.put("SYSZDF","0");
							}else{
								dataMap.put("SYSZDF",money);
							}
							//dataMap.put("SYSZDF", MapUtils.getString(costRecord, "costMoney"));
						}
					}

					if(syszdfCount==0) {
						dataMap.put("SYSZDF","0");
					}

					// 影像学诊断费
					int yxxzdfCount = 0;
					for (Map<String, Object> costRecord : costRecords) {
						String medicalCostTypeCode = MapUtils.getString(costRecord, "medicalCostTypeCode");
						if ("C02003".equals(medicalCostTypeCode)) {
							yxxzdfCount++;
							String money = MapUtils.getString(costRecord, "costMoney");
							if(money == null){
								dataMap.put("YXXZDF","0");
							}else{
								dataMap.put("YXXZDF",money);
							}
							//dataMap.put("YXXZDF", MapUtils.getString(costRecord, "costMoney"));
						}
					}

					if(yxxzdfCount==0) {
						dataMap.put("YXXZDF","0");
					}

					// 临床诊断项目费
					int lczdxmfCount = 0;
					for (Map<String, Object> costRecord : costRecords) {
						String medicalCostTypeCode = MapUtils.getString(costRecord, "medicalCostTypeCode");
						if ("C02004".equals(medicalCostTypeCode)) {
							lczdxmfCount++;
							String money = MapUtils.getString(costRecord, "costMoney");
							if(money == null){
								dataMap.put("LCZDXMF","0");
							}else{
								dataMap.put("LCZDXMF",money);
							}
							//dataMap.put("LCZDXMF", MapUtils.getString(costRecord, "costMoney"));
						}
					}

					if(lczdxmfCount==0) {
						dataMap.put("LCZDXMF","0");
					}

					// 治疗类：(9)非手术治疗项目费
					int fsszlxmfCount = 0;
					for (Map<String, Object> costRecord : costRecords) {
						String medicalCostTypeCode = MapUtils.getString(costRecord, "medicalCostTypeCode");
						if ("C03001".equals(medicalCostTypeCode)) {
							fsszlxmfCount++;
							String money = MapUtils.getString(costRecord, "costMoney");
							if(money == null){
								dataMap.put("FSSZLXMF","0");
							}else{
								dataMap.put("FSSZLXMF",money);
							}
							//dataMap.put("FSSZLXMF", MapUtils.getString(costRecord, "costMoney"));
						}
					}

					if(fsszlxmfCount==0) {
						dataMap.put("FSSZLXMF","0");
					}

					// 临床物理治疗费
					int wlzlfCount = 0;
					for (Map<String, Object> costRecord : costRecords) {
						String medicalCostTypeCode = MapUtils.getString(costRecord, "medicalCostTypeCode");
						if ("C03002".equals(medicalCostTypeCode)) {
							wlzlfCount++;
							String money = MapUtils.getString(costRecord, "costMoney");
							if(money == null){
								dataMap.put("WLZLF","0");
							}else{
								dataMap.put("WLZLF",money);
							}
							//dataMap.put("WLZLF", MapUtils.getString(costRecord, "costMoney"));
						}
					}
					if(wlzlfCount==0) {
						dataMap.put("WLZLF","0");
					}

					// 手术治疗费
					int sszlfCount = 0;
					for (Map<String, Object> costRecord : costRecords) {
						String medicalCostTypeCode = MapUtils.getString(costRecord, "medicalCostTypeCode");
						if ("C03003".equals(medicalCostTypeCode)) {
							sszlfCount++;
							String money = MapUtils.getString(costRecord, "costMoney");
							if(money == null){
								dataMap.put("SSZLF","0");
							}else{
								dataMap.put("SSZLF",money);
							}
							//dataMap.put("SSZLF", MapUtils.getString(costRecord, "costMoney"));
						}
					}
					if(sszlfCount==0) {
						dataMap.put("SSZLF","0");
					}

					// 麻醉费
					int mafCount = 0 ;
					for (Map<String, Object> costRecord : costRecords) {
						String medicalCostTypeCode = MapUtils.getString(costRecord, "medicalCostTypeCode");
						if ("C03004".equals(medicalCostTypeCode)) {
							mafCount++;
							String money = MapUtils.getString(costRecord, "costMoney");
							if(money == null){
								dataMap.put("MAF","0");
							}else{
								dataMap.put("MAF",money);
							}
							//dataMap.put("MAF", MapUtils.getString(costRecord, "costMoney"));
						}
					}
					if(mafCount==0) {
						dataMap.put("MAF","0");
					}

					// 手术费
					int ssfCount = 0;
					for (Map<String, Object> costRecord : costRecords) {
						String medicalCostTypeCode = MapUtils.getString(costRecord, "medicalCostTypeCode");
						if ("C03005".equals(medicalCostTypeCode)) {
							ssfCount++;
							String money = MapUtils.getString(costRecord, "costMoney");
							if(money == null){
								dataMap.put("SSF","0");
							}else{
								dataMap.put("SSF",money);
							}
							//dataMap.put("SSF", MapUtils.getString(costRecord, "costMoney"));
						}
					}
					if(ssfCount==0) {
						dataMap.put("SSF","0");
					}

					// 康复类：(11)康复费
					int kffCount = 0;
					for (Map<String, Object> costRecord : costRecords) {
						String medicalCostTypeCode = MapUtils.getString(costRecord, "medicalCostTypeCode");
						if ("C04001".equals(medicalCostTypeCode)) {
							kffCount++;
							String money = MapUtils.getString(costRecord, "costMoney");
							if(money == null){
								dataMap.put("KFF","0");
							}else{
								dataMap.put("KFF",money);
							}
							//dataMap.put("KFF", MapUtils.getString(costRecord, "costMoney"));
						}
					}
					if(kffCount==0) {
						dataMap.put("KFF","0");
					}

					// 中医类:(12)中医治疗费
					int zyzlfCount = 0;
					for (Map<String, Object> costRecord : costRecords) {
						String medicalCostTypeCode = MapUtils.getString(costRecord, "medicalCostTypeCode");
						if ("C05001".equals(medicalCostTypeCode)) {
							zyzlfCount++;
							String money = MapUtils.getString(costRecord, "costMoney");
							if(money == null){
								dataMap.put("ZYZLF","0");
							}else{
								dataMap.put("ZYZLF",money);
							}
							//dataMap.put("ZYZLF", MapUtils.getString(costRecord, "costMoney"));
						}
					}
					if(zyzlfCount==0) {
						dataMap.put("ZYZLF","0");
					}

					// 西药类:(13)西药费
					int xyfCount = 0;
					for (Map<String, Object> costRecord : costRecords) {
						String medicalCostTypeCode = MapUtils.getString(costRecord, "medicalCostTypeCode");
						if ("C06001".equals(medicalCostTypeCode)) {
							xyfCount++;
							String money = MapUtils.getString(costRecord, "costMoney");
							if(money == null){
								dataMap.put("XYF","0");
							}else{
								dataMap.put("XYF",money);
							}
							//dataMap.put("XYF", MapUtils.getString(costRecord, "costMoney"));
						}
					}
					if(xyfCount==0) {
						dataMap.put("XYF","0");
					}

					// 抗菌药物费
					int kjywfCount = 0;
					for (Map<String, Object> costRecord : costRecords) {
						String medicalCostTypeCode = MapUtils.getString(costRecord, "medicalCostTypeCode");
						if ("C06002".equals(medicalCostTypeCode)) {
							kjywfCount++;
							String money = MapUtils.getString(costRecord, "costMoney");
							if(money == null){
								dataMap.put("KJYWF","0");
							}else{
								dataMap.put("KJYWF",money);
							}
							//dataMap.put("KJYWF", MapUtils.getString(costRecord, "costMoney"));
						}
					}
					if(kjywfCount==0) {
						dataMap.put("KJYWF","0");
					}

					// 中药类:(14)中成药费
					int zcyfCount = 0;
					for (Map<String, Object> costRecord : costRecords) {
						String medicalCostTypeCode = MapUtils.getString(costRecord, "medicalCostTypeCode");
						if ("C07001".equals(medicalCostTypeCode)) {
							zcyfCount++;
							String money = MapUtils.getString(costRecord, "costMoney");
							if(money == null){
								dataMap.put("ZCYF","0");
							}else{
								dataMap.put("ZCYF",money);
							}
							//dataMap.put("ZCYF", MapUtils.getString(costRecord, "costMoney"));
						}
					}
					if(zcyfCount==0) {
						dataMap.put("ZCYF","0");
					}

					// 中草药费
					int zcyf1Count = 0;
					for (Map<String, Object> costRecord : costRecords) {
						String medicalCostTypeCode = MapUtils.getString(costRecord, "medicalCostTypeCode");
						if ("C07002".equals(medicalCostTypeCode)) {
							zcyf1Count++;
							String money = MapUtils.getString(costRecord, "costMoney");
							if(money == null){
								dataMap.put("ZCYF1","0");
							}else{
								dataMap.put("ZCYF1",money);
							}
							//dataMap.put("ZCYF1", MapUtils.getString(costRecord, "costMoney"));
						}
					}
					if(zcyf1Count==0) {
						dataMap.put("ZCYF1","0");
					}

					// 血液和血液制品类:(16)血费
					int xfCount = 0;
					for (Map<String, Object> costRecord : costRecords) {
						String medicalCostTypeCode = MapUtils.getString(costRecord, "medicalCostTypeCode");
						if ("C08001".equals(medicalCostTypeCode)) {
							xfCount++;
							String money = MapUtils.getString(costRecord, "costMoney");
							if(money == null){
								dataMap.put("XF","0");
							}else{
								dataMap.put("XF",money);
							}
							//dataMap.put("XF", MapUtils.getString(costRecord, "costMoney"));
						}
					}
					if(xfCount==0) {
						dataMap.put("XF","0");
					}

					// 白蛋白类制品费
					int bdblzpfCount = 0;
					for (Map<String, Object> costRecord : costRecords) {
						String medicalCostTypeCode = MapUtils.getString(costRecord, "medicalCostTypeCode");
						if ("C08002".equals(medicalCostTypeCode)) {
							bdblzpfCount++;
							String money = MapUtils.getString(costRecord, "costMoney");
							if(money == null){
								dataMap.put("BDBLZPF","0");
							}else{
								dataMap.put("BDBLZPF",money);
							}
							//dataMap.put("BDBLZPF", MapUtils.getString(costRecord, "costMoney"));
						}
					}
					if(bdblzpfCount==0) {
						dataMap.put("BDBLZPF","0");
					}

					// 球蛋白类制品费
					int qdblzpfCount = 0;
					for (Map<String, Object> costRecord : costRecords) {
						String medicalCostTypeCode = MapUtils.getString(costRecord, "medicalCostTypeCode");
						if ("C08003".equals(medicalCostTypeCode)) {
							qdblzpfCount++;
							String money = MapUtils.getString(costRecord, "costMoney");
							if(money == null){
								dataMap.put("QDBLZPF","0");
							}else{
								dataMap.put("QDBLZPF",money);
							}
							//dataMap.put("QDBLZPF", MapUtils.getString(costRecord, "costMoney"));
						}
					}
					if(qdblzpfCount==0) {
						dataMap.put("QDBLZPF","0");
					}

					// 凝血因子类制品费
					int nxyzlzpfCount = 0;
					for (Map<String, Object> costRecord : costRecords) {
						String medicalCostTypeCode = MapUtils.getString(costRecord, "medicalCostTypeCode");
						if ("C08004".equals(medicalCostTypeCode)) {
							nxyzlzpfCount++;
							String money = MapUtils.getString(costRecord, "costMoney");
							if(money == null){
								dataMap.put("NXYZLZPF","0");
							}else{
								dataMap.put("NXYZLZPF",money);
							}
							//dataMap.put("NXYZLZPF", MapUtils.getString(costRecord, "costMoney"));
						}
					}
					if(qdblzpfCount==0) {
						dataMap.put("NXYZLZPF","0");
					}

					// 细胞因子类制品费
					int xbyzlzpfCount = 0;
					for (Map<String, Object> costRecord : costRecords) {
						String medicalCostTypeCode = MapUtils.getString(costRecord, "medicalCostTypeCode");
						if ("C08005".equals(medicalCostTypeCode)) {
							xbyzlzpfCount++;
							String money = MapUtils.getString(costRecord, "costMoney");
							if(money == null){
								dataMap.put("XBYZLZPF","0");
							}else{
								dataMap.put("XBYZLZPF",money);
							}
							//dataMap.put("XBYZLZPF", MapUtils.getString(costRecord, "costMoney"));
						}
					}
					if(xbyzlzpfCount==0) {
						dataMap.put("XBYZLZPF","0");
					}

					// 耗材类:(21)检查用一次性医用材料费
					int hcyyclfCount = 0;
					for (Map<String, Object> costRecord : costRecords) {
						String medicalCostTypeCode = MapUtils.getString(costRecord, "medicalCostTypeCode");
						if ("C09001".equals(medicalCostTypeCode)) {
							hcyyclfCount++;
							String money = MapUtils.getString(costRecord, "costMoney");
							if(money == null){
								dataMap.put("HCYYCLF","0");
							}else{
								dataMap.put("HCYYCLF",money);
							}
							//dataMap.put("HCYYCLF", MapUtils.getString(costRecord, "costMoney"));
						}
					}
					if(hcyyclfCount==0) {
						dataMap.put("HCYYCLF","0");
					}

					// (22)治疗用一次性医用材料费
					int yyclfCount = 0;
					for (Map<String, Object> costRecord : costRecords) {
						String medicalCostTypeCode = MapUtils.getString(costRecord, "medicalCostTypeCode");
						if ("C09002".equals(medicalCostTypeCode)) {
							yyclfCount++;
							String money = MapUtils.getString(costRecord, "costMoney");
							if(money == null){
								dataMap.put("YYCLF","0");
							}else{
								dataMap.put("YYCLF",money);
							}
							//dataMap.put("YYCLF", MapUtils.getString(costRecord, "costMoney"));
						}
					}
					if(yyclfCount==0) {
						dataMap.put("YYCLF","0");
					}

					// (23)手术用一次性医用材料费
					int ycxyyclfCount = 0;
					for (Map<String, Object> costRecord : costRecords) {
						String medicalCostTypeCode = MapUtils.getString(costRecord, "medicalCostTypeCode");
						if ("C09003".equals(medicalCostTypeCode)) {
							ycxyyclfCount++;
							String money = MapUtils.getString(costRecord, "costMoney");
							if(money == null){
								dataMap.put("YCXYYCLF","0");
							}else{
								dataMap.put("YCXYYCLF",money);
							}
							//dataMap.put("YCXYYCLF", MapUtils.getString(costRecord, "costMoney"));
						}
					}
					if(ycxyyclfCount==0) {
						dataMap.put("YCXYYCLF","0");
					}

					// 其他类：(24)其他费
					int qtfCount = 0;
					for (Map<String, Object> costRecord : costRecords) {
						String medicalCostTypeCode = MapUtils.getString(costRecord, "medicalCostTypeCode");
						if ("C99999".equals(medicalCostTypeCode)) {
							qtfCount++;
							String money = MapUtils.getString(costRecord, "costMoney");
							if(money == null){
								dataMap.put("QTF","0");
							}else{
								dataMap.put("QTF",money);
							}
							//dataMap.put("QTF", MapUtils.getString(costRecord, "costMoney"));
						}
					}
					if(qtfCount==0) {
						dataMap.put("QTF","0");
					}
				}
			} else {
				dataMap.put("ZFY", "0");

				dataMap.put("ZFJE", "0");
			}

			//System.out.println(dataMap);
			dataList.add(dataMap);
		}

		return dataList;
	}


	public static Map<String,Object> getDeptMap(){
		Map<String,Object> map = new HashMap<>();
		//map.put("2001", "03.05");
		map.put("2001", "19.10");
		map.put("2002", "03.05");
		map.put("2003", "03.04");

		map.put("2004", "03.04");
		map.put("2005", "03.06");
		map.put("2006", "03.07");
		map.put("2007", "03.03");
		map.put("2008", "03.03");
		map.put("20106", "03.03");


		map.put("2009", "16");
		map.put("2010", "03.02");
		map.put("2011", "03.01");
		map.put("2038", "03.01");
		map.put("2012", "04.01");
		map.put("2013", "04.01");
		map.put("2014", "08");
		//map.put("2015", "04.01");
		map.put("2015", "04.01.13");
		// 骨科一区病区
		map.put("2016", "04.03");
		// 骨科二区病区
		map.put("2017", "04.03");
		// 骨科一病区单元
		map.put("20045", "04.03");
		// 骨科一病区
		map.put("20059", "04.03");
		map.put("2018", "04.05");
		map.put("2019", "04.04");
		map.put("2020", "04.02");

		map.put("2021", "05.01");
		map.put("2022", "05.02");
		map.put("2023", "05.02");
		map.put("2024", "05.02");
		map.put("2025", "07");
		map.put("2026", "07");
		map.put("2027", "07");
		map.put("2028", "10");
		map.put("2029", "12");
		map.put("2030", "11");
		map.put("2031", "21");
		map.put("2032", "28");
		map.put("20001", "03.05");
		map.put("20201", "03.05");
		map.put("20002", "03.04");
		map.put("20003", "03.04");

		map.put("20004", "03.06");
		map.put("20005", "03.07");
		map.put("20006", "03.03");
		map.put("20007", "03.03");
		map.put("20106", "03.03");

		map.put("20008", "16");
		map.put("20009", "03.02");
		map.put("20010", "03.01");
		map.put("20110", "03.01");

		map.put("20011", "04.01");

		map.put("20012", "04.01");
		map.put("20018", "08");
		map.put("20013", "04.01");
		map.put("20059", "04.03");
		map.put("20014", "04.03");
		map.put("20015", "04.05");

		map.put("20016", "04.04");
		map.put("20017", "04.02");
		map.put("20019", "05.01");
		map.put("20058", "05.02");
		map.put("20057", "05.02");
		map.put("20071", "05.02");


		map.put("20023", "07");
		map.put("20024", "07");
		map.put("20025", "07");
		map.put("20026", "10");
		map.put("20028", "12");
		map.put("20027", "11");

		map.put("20072", "21");
		map.put("20029", "28");
		map.put("30011", "21");
		map.put("20058", "05.02");
		// 骨科二病区
		map.put("20014", "04.03");

		map.put("20057", "05.02");
		// 骨科二病区单元
		map.put("20145", "04.03");

		// 手足外科
		map.put("2043", "04.03.13");
		// 急诊医学科病区
		map.put("2041", "20");
		// 儿科扩展病区
		map.put("2056", "07");
		//2063  中医日间病房一病区
		map.put("2063", "50");
		// 中医日间病房二病区
		map.put("2067", "50");
		// 安宁疗护一病区
		map.put("2064", "24");
		// 安宁疗护二病区
		map.put("2065", "24");
		// 安宁疗护三病区
		map.put("2066", "24");
		// 肿瘤日间病房一病区
		map.put("2068", "19");
		// 肿瘤日间病房二病区
		map.put("2069", "19");
		// 重症医学科扩展病房
		map.put("2048", "28");
		return map;

	}

	public static Map<String,Object> getNationlityMap(){
		Map<String,Object> nationlityMap = new HashMap<>();
		nationlityMap.put("中国", "CHN");
		nationlityMap.put("澳大利亚", "AUS");
		nationlityMap.put("安哥拉", "AGO");
		nationlityMap.put("加拿大", "CAN");
		nationlityMap.put("古巴", "CUB");
		nationlityMap.put("日本", "JPN");
		nationlityMap.put("英国", "GBR");
		nationlityMap.put("美国", "UAS");
		nationlityMap.put("越南", "VNM");
		nationlityMap.put("国籍不详", "ZZZ");

		return nationlityMap;
//		.
//
//		.
//
//		AGO.安哥拉
//		AIA.安圭拉
//		ALB.阿尔巴尼亚
//		AND.安道尔
//		ANT.荷属安的列斯
//		ARE.阿联酋
//		ARG.阿根廷
//		ARM.亚美尼亚
//		ASM.美属萨摩亚
//		ATA.南极洲
//		ATF.法属南部领土
//		ATG.安提瓜和巴布达
//		AUS.澳大利亚
//		AUT.奥地利
//		AZE.阿塞拜疆
//		BDI.布隆迪
//		BEL.比利时
//		BEN.贝宁
//		BFA.布基纳法索
//		BGD.孟加拉国
//		BGR.保加利亚
//		BHR.巴林
//		BHS.巴哈马
//		BIH.波黑
//		BLR.白俄罗斯
//		BLZ.伯利兹
//		BMU.百慕大
//		BOL.玻利维亚
//		BRA.巴西
//		BRB.巴巴多斯
//		BRN.文莱
//		BTN.不丹
//		BVT.布维岛
//		BWA.博茨瓦纳
//		CAF.中非
//		CAN.加拿大
//		CCK.科科斯(基林)群岛
//		CHE.瑞士
//		CHL.智利
//		CHN.中国
//		CIV.科特迪瓦
//		CMR.喀麦隆
//		COD.刚果（金）
//		COG.刚果（布）
//		COK.库克群岛
//		COL.哥伦比亚
//		COM.科摩罗
//		CPV.佛得角
//		CR.哥斯达黎加
//		CSR.圣诞岛
//		CUB.古巴
//		CYM.开曼群岛
//		CYP.塞浦路斯
//		CZE.捷克
//		DEU.德国
//		DJI.吉布提
//		DMA.多米尼克
//		DNK.丹麦
//		DOM.多米尼加共和国
//		DZA.阿尔及利亚
//		ECU.厄瓜多尔
//		EGY.埃及
//		ERI.厄立特里亚
//		ESH.西撒哈拉
//		ESP.西班牙
//		EST.爱沙尼亚
//		ETH.埃塞俄比亚
//		FIN.芬兰
//		FJI.斐济
//		FLK.福克兰群岛(马尔维纳斯)
//		FRA.法国
//		FRO.法罗群岛
//		FSM.密克罗尼西亚联邦
//		GAB.加蓬
//		GBR.英国
//		GEO.格鲁吉亚
//		GHA.加纳
//		GIB.直布罗陀
//		GIN.几内亚
//		GLP.瓜德罗普
//		GMB.冈比亚Gambia
//		GNB.几内亚比绍
//		GNQ.赤道几内亚
//		GRC.希腊
//		GRD.格林纳达
//		GRL.格陵兰
//		GTM.危地马拉
//		GUF.法属圭亚那
//		GUM.关岛
//		GUY.圭亚那
//		HKG.香港
//		HMD.赫德岛和麦克唐纳岛
//		HND.洪都拉斯
//		HRV.克罗地亚
//		HTI.海地
//		HUN.匈牙利
//		IDN.印度尼西亚
//		IND.印度
//		IOT.英属印度洋领土
//		IRL.爱尔兰
//		IRN.伊朗
//		IRQ.伊拉克
//		ISL.冰岛
//		ISR.以色列
//		ITA.意大利
//		JAM.牙买加
//		JOR.约旦
//		JPN.日本
//		KAZ.哈萨克斯坦
//		KEN.肯尼亚
//		KGZ.吉尔吉斯斯坦
//		KHM.柬埔寨
//		KIR.基里巴斯
//		KNA.圣基茨和尼维斯
//		KOR.韩国
//		KWT.科威特
//		LAO.老挝
//		LBN.黎巴嫩
//		LBR.利比里亚
//		LBY.利比亚
//		LCA.圣卢西亚
//		LIE.列支敦士登
//		LKA.斯里兰卡
//		LSO.莱索托
//		LTU.立陶宛
//		LUX.卢森堡
//		LVA.拉脱维亚
//		MAC.澳门
//		MAR.摩洛哥
//		MCO.摩纳哥
//		MDA.摩尔多瓦
//		MDG.马达加斯加
//		MDV.马尔代夫
//		MEX.墨西哥
//		MHL.马绍尔群岛
//		MKD.前南马其顿
//		MLI.马里
//		MLT.马耳他
//		MMR.缅甸
//		MNG.蒙古
//		MNP.北马里亚纳
//		MOZ.莫桑比克
//		MRT.毛里塔尼亚
//		MSR.蒙特塞拉特
//		MTQ.马提尼克
//		MUS.毛里求斯
//		MWI.马拉维
//		MYS.马来西亚
//		MYT.马约特
//		NAM.纳米比亚
//		NCL.新喀里多尼亚
//		NER.尼日尔
//		NFK.诺福克岛
//		NGA.尼日利亚
//		NIC.尼加拉瓜
//		NIU.纽埃
//		NLD.荷兰
//		NOR.挪威
//		NPL.尼泊尔
//		NRU.瑙鲁
//		NZL.新西兰
//		OMN.阿曼
//		PAK.巴基斯坦
//		PAN.巴拿马
//		PCN.皮特凯恩群岛
//		PER.秘鲁
//		PHL.菲律宾
//		PLW.帕劳
//		PNG.巴布亚新几内亚
//		POL.波兰
//		PRI.波多黎各
//		PRK.朝鲜
//		PRT.葡萄牙
//		PRY.巴拉圭
//		PST.巴勒斯坦
//		PYF.法属波利尼西亚
//		QAT.卡塔尔
//		REU.留尼汪
//		ROM.罗马尼亚
//		RUS.俄罗斯联邦
//		RWA.卢旺达
//		SAU.沙特阿拉伯
//		SDN.苏丹
//		SEN.塞内加尔
//		SGP.新加坡
//		SGS.南乔治亚岛和南桑德韦奇岛
//		SHN.圣赫勒拿
//		SJM.斯瓦尔巴群岛
//		SLB.所罗门群岛
//		SLE.塞拉利昂
//		SLV.萨尔瓦多
//		SMR.圣马力诺
//		SOM.索马里
//		SPM.圣皮埃尔和密克隆
//		STp.圣多美和普林西比
//		SUR.苏里南
//		SVK.斯洛伐克
//		SVN.斯洛文尼亚
//		SWE.瑞典
//		SWZ.斯威士兰
//		SYC.塞舌尔
//		SYR.叙利亚
//		TCA.特克斯科斯群岛
//		TCD.乍得
//		TGO.多哥
//		THA.泰国
//		TJK.塔吉克斯坦
//		TKL.托克劳
//		TKM.土库曼斯坦
//		TMP.东帝汶
//		TON.汤加
//		TTO.特立尼达和多巴哥
//		TUN.突尼斯
//		TUR.土耳其
//		TUV.图瓦卢
//		TWN.台湾
//		TZA.坦桑尼亚
//		UGA.乌干达
//		UKR.乌克兰
//		UMI.美国本土外小岛屿
//		URY.乌拉圭
//		USA.美国
//		UZB.乌兹别克斯坦
//		VAT.梵蒂冈
//		VCT.圣文森特和格林纳丁斯
//		VEN.委内瑞拉
//		VGB.英属维尔京群岛
//		VIR.美属维尔京群岛
//		VNM.越南
//		VUT.瓦努阿图
//		WLF.瓦利斯和富图纳
//		WSM.萨摩亚
//		YEM.也门
//		YUG.南斯拉夫
//		ZAF.南非
//		ZMB.赞比亚
//		ZWE.津巴布韦
//		ZZZ.国籍不详
	}


	private String[] hqmsHomePageHeader = { "A01", "A02", "A48", "A49", "B12", "B15", "A47", "A46C", "A11", "A12C", "A13", "A14",
			"A15C", "A21C", "A38C", "A19C", "A20N", "A20", "A22", "A23C", "A24", "A25C", "A26", "A27", "A28C", "A29",
			"A30", "A31C", "A32", "A33C", "A34", "A35", "B38", "B11C", "B13C", "B14", "B21C", "B16C", "B17", "B20",
			"C01C", "C02N", "F01", "F02C", "F03N", "F04", "C03C", "C04N", "C05C", "F05", "C06x01C", "C07x01N",
			"C08x01C", "F06x01", "C06x02C", "C07x02N", "C08x02C", "F06x02", "C06x03C", "C07x03N", "C08x03C", "F06x03",
			"C06x04C", "C07x04N", "C08x04C", "F06x04", "C06x05C", "C07x05N", "C08x05C", "F06x05", "C06x06C", "C07x06N",
			"C08x06C", "F06x06", "C06x07C", "C07x07N", "C08x07C", "F06x07", "C06x08C", "C07x08N", "C08x08C", "F06x08",
			"C06x09C", "C07x09N", "C08x09C", "F06x09", "C06x10C", "C07x10N", "C08x10C", "F06x10", "C06x11C", "C07x11N",
			"C08x11C", "F06x11", "C06x12C", "C07x12N", "C08x12C", "F06x12", "C06x13C", "C07x13N", "C08x13C", "F06x13",
			"C06x14C", "C07x14N", "C08x14C", "F06x14", "C06x15C", "C07x15N", "C08x15C", "F06x15", "C06x16C", "C07x16N",
			"C08x16C", "F06x16", "C06x17C", "C07x17N", "C08x17C", "F06x17", "C06x18C", "C07x18N", "C08x18C", "F06x18",
			"C06x19C", "C07x19N", "C08x19C", "F06x19", "C06x20C", "C07x20N", "C08x20C", "F06x20", "C06x21C", "C07x21N",
			"C08x21C", "F06x21", "C06x22C", "C07x22N", "C08x22C", "F06x22", "C06x23C", "C07x23N", "C08x23C", "F06x23",
			"C06x24C", "C07x24N", "C08x24C", "F06x24", "C06x25C", "C07x25N", "C08x25C", "F06x25", "C06x26C", "C07x26N",
			"C08x26C", "F06x26", "C06x27C", "C07x27N", "C08x27C", "F06x27", "C06x28C", "C07x28N", "C08x28C", "F06x28",
			"C06x29C", "C07x29N", "C08x29C", "F06x29", "C06x30C", "C07x30N", "C08x30C", "F06x30", "C06x31C", "C07x31N",
			"C08x31C", "F06x31", "C06x32C", "C07x32N", "C08x32C", "F06x32", "C06x33C", "C07x33N", "C08x33C", "F06x33",
			"C06x34C", "C07x34N", "C08x34C", "F06x34", "C06x35C", "C07x35N", "C08x35C", "F06x35", "C06x36C", "C07x36N",
			"C08x36C", "F06x36", "C06x37C", "C07x37N", "C08x37C", "F06x37", "C06x38C", "C07x38N", "C08x38C", "F06x38",
			"C06x39C", "C07x39N", "C08x39C", "F06x39", "C06x40C", "C07x40N", "C08x40C", "F06x40", "C09C", "C10N", "C11",
			"F07x01C", "F08x01N", "F09x01", "F07x02C", "F08x02N", "F09x02", "C12C", "C13N", "C24C", "C25", "F10", "F11",
			"F12", "B22C", "B22", "B23C", "B23", "B24C", "B24", "B25C", "B25", "B26C", "B26", "B27", "B28", "B29",
			"B30C", "B31", "B32", "B33", "C34C", "C26C", "C27C", "C14x01C", "C15x01N", "C16x01", "C17x01", "F13",
			"C18x01", "C19x01", "C20x01", "C21x01C", "C22x01C", "F15", "C23x01", "C35x01C", "C36x01N", "C37x01",
			"C38x01", "F14x01", "C39x01", "C40x01", "C41x01", "C42x01C", "C43x01C", "F16x01", "C44x01", "C35x02C",
			"C36x02N", "C37x02", "C38x02", "F14x02", "C39x02", "C40x02", "C41x02", "C42x02C", "C43x02C", "F16x02",
			"C44x02", "C35x03C", "C36x03N", "C37x03", "C38x03", "F14x03", "C39x03", "C40x03", "C41x03", "C42x03C",
			"C43x03C", "F16x03", "C44x03", "C35x04C", "C36x04N", "C37x04", "C38x04", "F14x04", "C39x04", "C40x04",
			"C41x04", "C42x04C", "C43x04C", "F16x04", "C44x04", "C35x05C", "C36x05N", "C37x05", "C38x05", "F14x05",
			"C39x05", "C40x05", "C41x05", "C42x05C", "C43x05C", "F16x05", "C44x05", "C35x06C", "C36x06N", "C37x06",
			"C38x06", "F14x06", "C39x06", "C40x06", "C41x06", "C42x06C", "C43x06C", "F16x06", "C44x06", "C35x07C",
			"C36x07N", "C37x07", "C38x07", "F14x07", "C39x07", "C40x07", "C41x07", "C42x07C", "C43x07C", "F16x07",
			"C44x07", "C35x08C", "C36x08N", "C37x08", "C38x08", "F14x08", "C39x08", "C40x08", "C41x08", "C42x08C",
			"C43x08C", "F16x08", "C44x08", "C35x09C", "C36x09N", "C37x09", "C38x09", "F14x09", "C39x09", "C40x09",
			"C41x09", "C42x09C", "C43x09C", "F16x09", "C44x09", "C35x10C", "C36x10N", "C37x10", "C38x10", "F14x10",
			"C39x10", "C40x10", "C41x10", "C42x10C", "C43x10C", "F16x10", "C44x10", "C35x11C", "C36x11N", "C37x11",
			"C38x11", "F14x11", "C39x11", "C40x11", "C41x11", "C42x11C", "C43x11C", "F16x11", "C44x11", "C35x12C",
			"C36x12N", "C37x12", "C38x12", "F14x12", "C39x12", "C40x12", "C41x12", "C42x12C", "C43x12C", "F16x12",
			"C44x12", "C35x13C", "C36x13N", "C37x13", "C38x13", "F14x13", "C39x13", "C40x13", "C41x13", "C42x13C",
			"C43x13C", "F16x13", "C44x13", "C35x14C", "C36x14N", "C37x14", "C38x14", "F14x14", "C39x14", "C40x14",
			"C41x14", "C42x14C", "C43x14C", "F16x14", "C44x14", "C35x15C", "C36x15N", "C37x15", "C38x15", "F14x15",
			"C39x15", "C40x15", "C41x15", "C42x15C", "C43x15C", "F16x15", "C44x15", "C35x16C", "C36x16N", "C37x16",
			"C38x16", "F14x16", "C39x16", "C40x16", "C41x16", "C42x16C", "C43x16C", "F16x16", "C44x16", "C35x17C",
			"C36x17N", "C37x17", "C38x17", "F14x17", "C39x17", "C40x17", "C41x17", "C42x17C", "C43x17C", "F16x17",
			"C44x17", "C35x18C", "C36x18N", "C37x18", "C38x18", "F14x18", "C39x18", "C40x18", "C41x18", "C42x18C",
			"C43x18C", "F16x18", "C44x18", "C35x19C", "C36x19N", "C37x19", "C38x19", "F14x19", "C39x19", "C40x19",
			"C41x19", "C42x19C", "C43x19C", "F16x19", "C44x19", "C35x20C", "C36x20N", "C37x20", "C38x20", "F14x20",
			"C39x20", "C40x20", "C41x20", "C42x20C", "C43x20C", "F16x20", "C44x20", "C35x21C", "C36x21N", "C37x21",
			"C38x21", "F14x21", "C39x21", "C40x21", "C41x21", "C42x21C", "C43x21C", "F16x21", "C44x21", "C35x22C",
			"C36x22N", "C37x22", "C38x22", "F14x22", "C39x22", "C40x22", "C41x22", "C42x22C", "C43x22C", "F16x22",
			"C44x22", "C35x23C", "C36x23N", "C37x23", "C38x23", "F14x23", "C39x23", "C40x23", "C41x23", "C42x23C",
			"C43x23C", "F16x23", "C44x23", "C35x24C", "C36x24N", "C37x24", "C38x24", "F14x24", "C39x24", "C40x24",
			"C41x24", "C42x24C", "C43x24C", "F16x24", "C44x24", "C35x25C", "C36x25N", "C37x25", "C38x25", "F14x25",
			"C39x25", "C40x25", "C41x25", "C42x25C", "C43x25C", "F16x25", "C44x25", "C35x26C", "C36x26N", "C37x26",
			"C38x26", "F14x26", "C39x26", "C40x26", "C41x26", "C42x26C", "C43x26C", "F16x26", "C44x26", "C35x27C",
			"C36x27N", "C37x27", "C38x27", "F14x27", "C39x27", "C40x27", "C41x27", "C42x27C", "C43x27C", "F16x27",
			"C44x27", "C35x28C", "C36x28N", "C37x28", "C38x28", "F14x28", "C39x28", "C40x28", "C41x28", "C42x28C",
			"C43x28C", "F16x28", "C44x28", "C35x29C", "C36x29N", "C37x29", "C38x29", "F14x29", "C39x29", "C40x29",
			"C41x29", "C42x29C", "C43x29C", "F16x29", "C44x29", "C35x30C", "C36x30N", "C37x30", "C38x30", "F14x30",
			"C39x30", "C40x30", "C41x30", "C42x30C", "C43x30C", "F16x30", "C44x30", "C35x31C", "C36x31N", "C37x31",
			"C38x31", "F14x31", "C39x31", "C40x31", "C41x31", "C42x31C", "C43x31C", "F16x31", "C44x31", "C35x32C",
			"C36x32N", "C37x32", "C38x32", "F14x32", "C39x32", "C40x32", "C41x32", "C42x32C", "C43x32C", "F16x32",
			"C44x32", "C35x33C", "C36x33N", "C37x33", "C38x33", "F14x33", "C39x33", "C40x33", "C41x33", "C42x33C",
			"C43x33C", "F16x33", "C44x33", "C35x34C", "C36x34N", "C37x34", "C38x34", "F14x34", "C39x34", "C40x34",
			"C41x34", "C42x34C", "C43x34C", "F16x34", "C44x34", "C35x35C", "C36x35N", "C37x35", "C38x35", "F14x35",
			"C39x35", "C40x35", "C41x35", "C42x35C", "C43x35C", "F16x35", "C44x35", "C35x36C", "C36x36N", "C37x36",
			"C38x36", "F14x36", "C39x36", "C40x36", "C41x36", "C42x36C", "C43x36C", "F16x36", "C44x36", "C35x37C",
			"C36x37N", "C37x37", "C38x37", "F14x37", "C39x37", "C40x37", "C41x37", "C42x37C", "C43x37C", "F16x37",
			"C44x37", "C35x38C", "C36x38N", "C37x38", "C38x38", "F14x38", "C39x38", "C40x38", "C41x38", "C42x38C",
			"C43x38C", "F16x38", "C44x38", "C35x39C", "C36x39N", "C37x39", "C38x39", "F14x39", "C39x39", "C40x39",
			"C41x39", "C42x39C", "C43x39C", "F16x39", "C44x39", "C35x40C", "C36x40N", "C37x40", "C38x40", "F14x40",
			"C39x40", "C40x40", "C41x40", "C42x40C", "C43x40C", "F16x40", "C44x40", "F17", "F18", "F19", "F20", "F21",
			"F22", "F23", "F24", "F25", "F26", "A16", "A18x01", "A18x02", "A18x03", "A18x04", "A18x05", "A17", "C28",
			"C29", "C30", "C31", "C32", "C33", "C47", "C48x01C", "C49x01", "C50x01", "C48x02C", "C49x02", "C50x02",
			"C48x03C", "C49x03", "C50x03", "C48x04C", "C49x04", "C50x04", "C48x05C", "C49x05", "C50x05", "B36C", "B37",
			"B34C", "B35", "D01", "D09", "D11", "D12", "D13", "D14", "D15", "D16", "D17", "D18", "D19", "D19x01", "D20",
			"D20x01", "D20x02", "D21", "D22", "D23", "D23x01", "D24", "D25", "D26", "D27", "D28", "D29", "D30", "D31",
			"D32", "D33", "D34"

	};


	public Map<String,Object> getMarriageMap(){
		Map<String,Object> marriageMap = new HashMap<>();
		marriageMap.put("未婚", "1");
		marriageMap.put("已婚", "2");
		marriageMap.put("丧偶", "3");
		marriageMap.put("离婚", "4");
		marriageMap.put("其他", "9");
		return marriageMap;
	}

	public static Map<String, Object> getHqmsDeptMap() {
		Map<String, Object> map = new HashMap<>();
		//心内科一区病区	0304
		map.put("心内科一区病区", "0304");
		//心内科二区病区	0304
		map.put("心内科二区病区", "0304");
		//血液肿瘤一区病区	19
		map.put("血液肿瘤科一区病区", "19");
		map.put("血液肿瘤科二区病区", "19");
		//血液肿瘤二区病区	0305
		map.put("血液肿瘤二病区", "19");
		map.put("血液肿瘤一病区", "19");
		//重症医学科病区	28
		map.put("重症医学科病区", "28");
		//骨科一区病区	0403
		map.put("骨科一区病区", "0403");
		map.put("骨科一病区", "0403");

		//心胸外科病区	0405
		map.put("心胸外科病区", "0405");
		//消化内科病区	0302
		map.put("消化内科病区", "0302");
		//泌尿外科病区	0404
		map.put("泌尿外科病区", "0404");
		//骨科二区病区	0403
		map.put("骨科二区病区", "0403");
		//神经内科一区病区	0303
		map.put("神经内科一区病区", "0303");
		//神经内科二区病区	0303
		map.put("神经内科二区病区", "0303");
		//神经外科病区 	0402
		map.put("神经外科病区", "0402");
		//新生儿科病区	0701
		map.put("新生儿科病区", "0701");
		//普外科二区病区	0401
		map.put("普外科二区病区", "0401");
		//普外科一区病区	0401
		map.put("普外科一区病区", "0401");
		//妇科病区	0501
		map.put("妇科病区", "0501");
		//呼吸与危重症医学科病区	0301
		map.put("呼吸与危重症医学科病区", "0301");
		map.put("呼吸与危重医学扩展病区", "0301");
		map.put("呼吸与危重症医学科扩展病区", "0301");
		//产科一区病区	0502
		map.put("产科一区病区", "0502");
		//产科二区病区	0502
		map.put("产科二区病区", "0502");
		//小儿外科病区	08
		map.put("小儿外科病区", "08");
		//产科三区病区	0502
		map.put("产科三区病区", "0502");
		//儿科一区病区	07
		map.put("儿科一区病区", "07");
		//康复医学科病区	21
		map.put("康复医学科病区", "21");
		//肾内科病区	0306
		map.put("肾内科病区", "0306");
		//肛肠外科病区	5011
		map.put("肛肠外科病区", "5011");
		//内分泌科病区	0307
		map.put("内分泌科病区", "0307");
		//口腔科病区	12
		map.put("口腔科病区", "12");
		//耳鼻喉病区	11
		map.put("耳鼻喉病区", "11");
		//耳鼻咽候科病区
		map.put("耳鼻咽喉科病区", "11");
		//感染性疾病科病区	16
		map.put("感染性疾病科病区", "16");
		//儿科二区病区	07
		map.put("儿科二区病区", "07");
		//眼科病区	10
		map.put("眼科病区", "10");

		map.put("手足外科病区", "0403");
		map.put("关节外科与创伤骨科病区", "0403");
		map.put("脊柱外科与创伤骨科病区", "0403");
		//胃肠外科肝胆外科病区
		map.put("胃肠外科肝胆外科病区", "0401");
		map.put("乳甲外科血管外科病区", "0401");
		map.put("感染性疾病科病区", "16");
		map.put("烧伤整形外科病区", "0407");
		map.put("烧伤整形病区", "0407");
		map.put("感染性疾病科扩展病区", "16");
		map.put("急诊医学科病区", "20");
		map.put("儿科扩展病区", "07");

		map.put("中医日间病房一病区", "50");
		map.put("中医日间病房二病区", "50");
		map.put("安宁疗护一病区", "24");
		map.put("安宁疗护二病区", "24");
		map.put("安宁疗护三病区", "24");

		map.put("肿瘤日间病房一区", "19");
		map.put("肿瘤日间病房二区", "19");
		map.put("重症医学科扩展病区", "28");
		return map;

	}







	public Map<String,Object> getPaymentMap(){
		Map<String,Object> map = new HashMap<>();
		//1.1 - 本市城镇职工基本医疗保险  01	城镇职工基本医疗保险
		map.put("01", "1.1");
		//2.1 - 本市城乡居民基本医疗保险  02	城镇居民基本医疗保险
		map.put("02", "2.1");
		//03	新型农村合作医疗  03	新型农村合作医疗
		map.put("03", "3.1");
		//04	贫困救助
		map.put("04", "4");
		//05	商业医疗保险
		map.put("05", "5");
		//06	全公费
		map.put("06", "6");
		//07	全自费
		map.put("07", "7");
		//08	其他社会保险
		map.put("08", "8");
		//99	其他
		map.put("99", "9");
		return map;
	}

	/**
	 * 省对应信息
	 * @return
	 */
	public Map<String,Object> getProvinceMap(){
		Map<String,Object> map = new HashMap<>();
		//1	1 - 北京市
		map.put("北京市", "1");
		//2	2 - 天津市
		map.put("天津市", "2");
		//3	3 - 河北省
		map.put("河北省", "3");
		//4	4 - 山西省
		map.put("山西省", "4");
		//5	5 - 内蒙古
		map.put("内蒙古", "5");
		//6	6 - 辽宁省
		map.put("辽宁省", "6");
		//7	7 - 吉林省
		map.put("吉林省", "7");
		//8	8 - 黑龙江省
		map.put("黑龙江省", "8");
		//9	9 - 上海市
		map.put("上海市", "9");
		//10	10 - 江苏省
		map.put("江苏省", "10");
		//11	11 - 浙江省
		map.put("浙江省", "11");
		//12	12 - 安徽省
		map.put("安徽省", "12");
		//13	13 - 福建省
		map.put("福建省", "13");
		//14	14 - 江西省
		map.put("江西省", "14");
		//15	15 - 山东省
		map.put("山东省", "15");
		//16	16 - 河南省
		map.put("河南省", "16");
		//17	17 - 湖北省
		map.put("湖北省", "17");
		//18	18 - 湖南省
		map.put("湖南省", "18");
		//19	19 - 广东省
		map.put("广东省", "19");
		//20	20 - 广西省
		map.put("广西省", "20");
		//21	21 - 海南省
		map.put("海南省", "21");
		//22	22 - 四川省
		map.put("四川省", "22");
		//23	23 - 重庆市
		map.put("重庆市", "23");
		//24	24 - 贵州省
		map.put("贵州省", "24");
		//25	25 - 云南省
		map.put("云南省", "25");
		//26	26 - 西藏
		map.put("西藏", "261");
		//27	27 - 陕西省
		map.put("陕西省", "27");
		//28	28 - 甘肃省
		map.put("甘肃省", "28");
		//29	29 - 青海省
		map.put("青海省", "29");
		//30	30 - 宁夏
		map.put("宁夏", "30");
		//31	31 - 新疆
		map.put("新疆", "31");
		//32	32 - 台湾
		map.put("台湾", "32");
		//33	33 - 香港特别行政区
		map.put("香港特别行政区", "33");
		//34	34 - 澳门
		map.put("澳门", "34");
		//35	35 –外籍
		map.put("外籍", "35");
		return map;
	}


	//0	0类切口	0 - 有手术，但体表无切口	有手术，但体表无切口或腔镜手术切口
	//1	Ⅰ类切口	1 - Ⅰ/甲	无菌切口/切口愈合良好
	//2		2 - Ⅰ/乙	无菌切口/切口愈合欠佳
	//3		3 - Ⅰ/丙	无菌切口/切口化脓
	//10		10 - Ⅰ/其他	无菌切口/切口愈合情况不确定
	//4	Ⅱ类切口	4 - Ⅱ/甲	沾染切口/切口愈合良好
	//5		5 - Ⅱ/乙	沾染切口/切口愈合欠佳
	//6		6 - Ⅱ/丙	沾染切口/切口化脓
	//20		20 - Ⅱ/其他	沾染切口/切口愈合情况不确定
	//7	Ⅲ类切口	7 - Ⅲ/甲	感染切口/切口愈合良好
	//8		8 - Ⅲ/乙	感染切口/切口愈合欠佳
	//9		9 - Ⅲ/丙	感染切口/切口化脓
	//30		30 - Ⅲ/其他	感染切口/切口愈合情况确定

	public String getIncisionHealLevel(String incisionLevel,String healLevel) {
		if(StringUtils.isNotEmpty(incisionLevel) && StringUtils.isNotEmpty(healLevel)) {
			//0类切口
			if("9".equals(incisionLevel) || "0".equals(incisionLevel)) {
				return "0";
			//Ⅰ类切口	1 - Ⅰ/甲	无菌切口/切口愈合良好
			}else if("1".equals(incisionLevel) && "1".equals(healLevel)) {
				return "1";
			}else if("1".equals(incisionLevel) && "2".equals(healLevel)) {
				return "2";
			}else if("1".equals(incisionLevel) && "3".equals(healLevel)) {
				return "3";
			}else if("1".equals(incisionLevel) && ("9".equals(healLevel)||"0".equals(healLevel))) {
				return "10";
			//Ⅱ类切口
			}else if("2".equals(incisionLevel) && "1".equals(healLevel)) {
				return "4";
			}else if("2".equals(incisionLevel) && "2".equals(healLevel)) {
				return "5";
			}else if("2".equals(incisionLevel) && "3".equals(healLevel)) {
				return "6";
			}else if("2".equals(incisionLevel) && ("9".equals(healLevel)||"0".equals(healLevel))) {
				return "20";
			//Ⅲ类切口
			}else if("3".equals(incisionLevel) && "1".equals(healLevel)) {
				return "7";
			}else if("3".equals(incisionLevel) && "2".equals(healLevel)) {
				return "8";
			}else if("3".equals(incisionLevel) && "3".equals(healLevel)) {
				return "9";
			}else if("3".equals(incisionLevel) && ("9".equals(healLevel)||"0".equals(healLevel))) {
				return "30";
			}
		}else if(StringUtils.isNotEmpty(incisionLevel) && StringUtils.isEmpty(healLevel)){
			if("0".equals(incisionLevel) || "9".equals(incisionLevel) ) {
				return "0";
			}else if("1".equals(incisionLevel)){
				return "10";
			}else if("2".equals(incisionLevel)){
				return "20";
			}else if("3".equals(incisionLevel)){
				return "30";
			}
		}else {
			return "0";
		}
		return null;
	}

	public Map<String,Object> getAnaesthesiaMap(){
		Map<String,Object> map = new HashMap<>();
		//	01	全身麻醉
		map.put("1", "01");
		//0101	吸入麻醉 （气管内插管、喉罩、面罩）
		map.put("11", "0101");
		//0102	静脉麻醉 （全凭静脉麻醉）
		map.put("12", "0102");
		//0103	静吸复合麻醉
		map.put("41", "0103");
		//0104	基础麻醉 （直肠注入、肌肉注射）
		map.put("13", "0104");
		//02	区域麻醉
		//map.put("2", "02");
		//0201	椎管内麻醉
		map.put("2", "0201");
		//020101	蛛网膜下腔阻滞 ||蛛网膜下腔阻滞麻醉
		map.put("21", "020101");
		//020102	硬膜外间隙阻滞（含骶管阻滞）||硬脊膜外腔阻滞麻醉
		map.put("22", "020102");
		//3 局部麻醉
		map.put("3", "03");
		//31 神经丛阻滞麻醉
		map.put("31", "0202");
		//32神经节阻滞麻醉
		map.put("32", "0202");
		//33神经阻滞麻醉
		map.put("33", "0202");
		//34 区域阻滞麻醉
		map.put("34", "99");
		//35局部浸润麻醉
		map.put("35", "0302");
		//36表面麻醉
		map.put("36", "0301");
		//4	复合麻醉
		map.put("4", "05");
		//41	静吸复合麻醉
		//map.put("41", "0502");
		//42	针药复合麻醉
		map.put("42", "0502");
		//43	神经丛与硬膜外阻滞复合麻醉
		map.put("43", "99");
		//44	全麻复合全身降温
		map.put("44", "0503");
		//45	全麻复合控制性降压
		map.put("45", "0503");
		//9	其他麻醉方法
		map.put("9", "99");
		//9	其他麻醉方法

		return map;
	}

	public Map<String,Object>  getHqmsDataByJson (String json) {
		Map<String, Object> jsonMap = JsonUtil.jsonToPojo(json, Map.class);
		if (MapUtils.isEmpty(jsonMap)) {
			return null;
		}
		Map<String, Object> map = new LinkedHashMap<>();
		Map<String, Object> basicInfoMap = (Map<String, Object>) MapUtils.getObject(jsonMap, "basicInfo");


		// 组织机构代码
		map.put("A01", "49417303137088111A1001");
		// 医疗机构名称
		map.put("A02", "曲阜市人民医院");
		// 病案号
		map.put("A48", MapUtils.getString(basicInfoMap, "mrId"));
		// 住院次数
		map.put("A49", MapUtils.getString(basicInfoMap, "visitNumber"));
		// 入院时间
		map.put("B12", MapUtils.getString(basicInfoMap, "inHospitalDateTime"));
		// 出院时间
		map.put("B15", MapUtils.getString(basicInfoMap, "outHospitalDateTime"));
		// 健康卡号
		map.put("A47", "-");
		// 医疗付费方式||值域范围参考RC032
		String medicalPayTypeCode =  MapUtils.getString(basicInfoMap, "medicalPayTypeCode");
		if(StringUtils.isNotBlank(medicalPayTypeCode)) {
			String  medicalPay = (String) getPaymentMap().get(medicalPayTypeCode);
			map.put("A46C", StringUtils.isEmpty(medicalPay)?"9":medicalPay);
		}else {
			map.put("A46C", "9");
		}
		// 姓名
		map.put("A11", MapUtils.getString(basicInfoMap, "patientName"));
		// 性别
		map.put("A12C", MapUtils.getString(basicInfoMap, "sexCode"));
		// 出生日期
		map.put("A13", MapUtils.getString(basicInfoMap, "birthday"));
		// 年龄（岁）
		map.put("A14", MapUtils.getString(basicInfoMap, "yearOfAge"));
		// 国籍
		String nationalityName = MapUtils.getString(basicInfoMap, "nationalityName");
		if(StringUtils.isNotBlank(nationalityName)) {
			String nationalityCode = (String) getNationlityMap().get(nationalityName);
			if(StringUtils.isEmpty(nationalityCode)) {
				map.put("A15C", MapUtils.getString(basicInfoMap, "CHN"));
			}else {
				map.put("A15C", nationalityCode);
			}
		}



		// 婚姻 A21C 值域范围参考RC002
		String marriageName = MapUtils.getString(basicInfoMap, "marriageName");
		if(StringUtils.isEmpty(marriageName)) {
			map.put("A21C", "9");
		}else {
			String marriageCode = (String) getMarriageMap().get(marriageName);
			if(StringUtils.isEmpty(marriageCode)) {
				map.put("A21C", "9");
			}else {
				map.put("A21C", marriageCode);
			}
		}

		// 职业
		map.put("A38C", MapUtils.getString(basicInfoMap, "professionCode"));
		// 民族
		String nationCode =  MapUtils.getString(basicInfoMap, "nationCode");
		if(StringUtils.isNotBlank(nationCode)) {
			if(nationCode.startsWith("0")) {
				nationCode = nationCode.replace("0", "");
			}
		}
		map.put("A19C", nationCode);
		// 证件类型
		map.put("A20N", "1");
		// 证件号码
		map.put("A20", MapUtils.getString(basicInfoMap, "idNumber"));
		// 出生地址
		map.put("A22", MapUtils.getString(basicInfoMap, "nativePlace"));

		Map<String, Object> nativePlaceRegionalismMap = (Map<String, Object>) MapUtils.getObject(basicInfoMap,
				"nativePlaceRegionalism");
		// 籍贯省（自治区、直辖市）
		if (nativePlaceRegionalismMap != null) {
			String provinceName = MapUtils.getString(nativePlaceRegionalismMap, "provinceName");
			String provinceValue = null;
			if(StringUtils.isNotBlank(provinceName)) {
					provinceValue = MapUtils.getString(getProvinceMap(), provinceName);

			}
				map.put("A23C", StringUtils.isEmpty(provinceValue)?"-":provinceValue);
			} else {
				map.put("A23C", "-");
			}
		// 户口地址
		map.put("A24", MapUtils.getString(basicInfoMap, "registeredAddress"));
		// 户口地址邮政编码
		map.put("A25C", MapUtils.getString(basicInfoMap, "registeredAddressPostCode"));

		Map<String, Object> permanentAddressRegionalismMap = (Map<String, Object>) MapUtils.getObject(basicInfoMap,
				"permanentAddressRegionalism");
		// 现住址
		map.put("A26", MapUtils.getString(permanentAddressRegionalismMap, "fullAddress"));
		// 现住址电话
		map.put("A27", MapUtils.getString(basicInfoMap, "permanentAddressPhone"));
		// 现住址邮政编码
		map.put("A28C", MapUtils.getString(basicInfoMap, "registeredAddressPostCode"));
		// 工作单位及地址
		map.put("A29", MapUtils.getString(basicInfoMap, "workUnitAddress"));
		// 工作单位电话
		map.put("A30", MapUtils.getString(basicInfoMap, "workUnitPhone"));
		// 工作单位邮政编码
	    String workUnitPostCode = MapUtils.getString(basicInfoMap, "workUnitPostCode");
		map.put("A31C", StringUtils.isEmpty(workUnitPostCode)?"-":workUnitPostCode);
		// 联系人姓名
		map.put("A32", MapUtils.getString(basicInfoMap, "linkManName"));
		// 联系人关系
		map.put("A33C", MapUtils.getString(basicInfoMap, "linkManRelativeRelationCode"));
		// 联系人地址
		map.put("A34", MapUtils.getString(basicInfoMap, "linkManAddress"));
		// 联系人电话
		map.put("A35", MapUtils.getString(basicInfoMap, "linkManPhone"));
		// 是否为日间手术
		map.put("B38", "0");
		// 入院途径

		String inHospitalTypeCode = MapUtils.getString(basicInfoMap, "inHospitalTypeCode");
		if(StringUtils.isNotBlank(inHospitalTypeCode)){
			if(inHospitalTypeCode.equals("1")){
				inHospitalTypeCode = "2";
			}else if(inHospitalTypeCode.equals("2")){
				inHospitalTypeCode = "1";
			}
			map.put("B11C", inHospitalTypeCode);
		}

		// 入院科别
		String inDeptName = MapUtils.getString(basicInfoMap, "inDeptName");
		if (StringUtils.isNotBlank(inDeptName)) {
			String hqmsDept = MapUtils.getString(getHqmsDeptMap(), inDeptName);
			if(StringUtils.isEmpty(hqmsDept)) {
				hqmsDept= "69";
			}
			map.put("B13C", hqmsDept);
		}else {
			map.put("B13C", "69");
		}
		String inDeptCode = MapUtils.getString(basicInfoMap, "inDeptCode");
		// 入院病房
		map.put("B14", StringUtils.isEmpty(inDeptCode) ? "-" : inDeptCode);
		// 转科科别
		map.put("B21C", "-");
		// 出院科别
		String outDeptCode = MapUtils.getString(basicInfoMap, "outDeptCode");
		String outDeptName = MapUtils.getString(basicInfoMap, "outDeptName");
		if (StringUtils.isNotBlank(outDeptName)) {
			String hqmsOutdept = MapUtils.getString(getHqmsDeptMap(), outDeptName);
			if(StringUtils.isEmpty(hqmsOutdept)) {
				hqmsOutdept = "69";
			}
				map.put("B16C", hqmsOutdept);
		}else {
			map.put("B16C", "69");
		}
		// 出院病房
		map.put("B17", StringUtils.isEmpty(outDeptCode) ? "-" : outDeptCode);
		// 实际住院（天）
		map.put("B20", MapUtils.getString(basicInfoMap, "inHospitalDayNumber"));

		// 疾病信息
		Map<String, Object> diseaseDiagInfoMap = (Map<String, Object>) MapUtils.getObject(jsonMap, "hqmsDiseaseDiagInfo");
		// 门诊信息
		Map<String, Object> outpatientDiagRecord = (Map<String, Object>) MapUtils.getObject(diseaseDiagInfoMap,
				"outpatientDiagRecord");
		// 门诊诊断编码
		map.put("C01C", MapUtils.getString(outpatientDiagRecord, "diseaseDiagCode"));
		// 门（急）诊诊断名称
		map.put("C02N", MapUtils.getString(outpatientDiagRecord, "diseaseDiagName"));
		// 入院情况
		map.put("F01", MapUtils.getString(basicInfoMap, "inHospitalStateCode"));
		// 入院诊断编码
		map.put("F02C", MapUtils.getString(outpatientDiagRecord, "diseaseDiagCode"));
		// 入院诊断名称
		map.put("F03N", MapUtils.getString(outpatientDiagRecord, "diseaseDiagName"));
		// 入院后确诊日期
		map.put("F04", null);
		// 主要诊断信息
		Map<String, Object> mainDiagRecord = (Map<String, Object>) MapUtils.getObject(diseaseDiagInfoMap,
				"mainDiagRecord");
		// 出院主要诊断编码
		map.put("C03C", MapUtils.getString(mainDiagRecord, "diseaseDiagCode"));
		// 出院主要诊断名称
		map.put("C04N", MapUtils.getString(mainDiagRecord, "diseaseDiagName"));
		// 出院主要诊断入院病情
		String inHospitalDiseaseStateCode = MapUtils.getString(mainDiagRecord, "inHospitalDiseaseStateCode");
		if(StringUtils.isEmpty(inHospitalDiseaseStateCode)) {
			inHospitalDiseaseStateCode = "4";
		}
		map.put("C05C", inHospitalDiseaseStateCode);

		// 主要诊断出院情况
		map.put("F05", null);
		// 其他诊断信息
		List<Map<String, Object>> diseaseDiagRecords = (List<Map<String, Object>>) MapUtils
				.getObject(diseaseDiagInfoMap, "diseaseDiagRecords");
		int otherDiagCount = 1;
		if(CollectionUtils.isNotEmpty(diseaseDiagRecords)){


		for (Map<String, Object> diseaseDiagRecord : diseaseDiagRecords) {
			String otherDiagIndex = otherDiagCount < 10 ? "0" + otherDiagCount : otherDiagCount + "";
			String otherDiseaseDiagCode = MapUtils.getString(diseaseDiagRecord, "diseaseDiagCode");
			String otherDiseaseDiagName = MapUtils.getString(diseaseDiagRecord, "diseaseDiagName");
			String otherInHospitalDiseaseStateCode = MapUtils.getString(diseaseDiagRecord,
					"inHospitalDiseaseStateCode");
			map.put("C06x" + otherDiagIndex + "C", otherDiseaseDiagCode);
			map.put("C07x" + otherDiagIndex + "N", otherDiseaseDiagName);
			map.put("C08x" + otherDiagIndex + "C", otherInHospitalDiseaseStateCode);
			map.put("F06x" + otherDiagIndex + "", null);
			otherDiagCount++;
		}
		}
		// 病理诊断信息
		List<Map<String, Object>> pathologyDiagRecords = (List<Map<String, Object>>) MapUtils
				.getObject(diseaseDiagInfoMap, "pathologyDiagRecords");
		int pathologyDiagCount = 1;
		if(CollectionUtils.isNotEmpty(pathologyDiagRecords)){
			for (Map<String, Object> pathologyDiagRecord : pathologyDiagRecords) {
				String diseaseDiagCode = MapUtils.getString(pathologyDiagRecord, "diseaseDiagCode");
				String diseaseDiagName = MapUtils.getString(pathologyDiagRecord, "diseaseDiagName");
				String pathologyNumber = MapUtils.getString(pathologyDiagRecord, "pathologyNumber");
				if (pathologyDiagCount == 1) {
					// 病理诊断编码
					map.put("C09C", diseaseDiagCode);
					// 病理诊断名称
					map.put("C10N", diseaseDiagName);
					// 病理号
					map.put("C11", pathologyNumber);
				} else if (pathologyDiagCount == 2) {
					// 病理诊断编码1
					map.put("F07x01C", diseaseDiagCode);
					// 病理诊断名称1
					map.put("F08x01N", diseaseDiagName);
					// 病理号1
					map.put("F09x01", pathologyNumber);
				} else if (pathologyDiagCount == 3) {
					// 病理诊断编码2
					map.put("F07x02C", diseaseDiagCode);
					// 病理诊断名称2
					map.put("F08x02N", diseaseDiagName);
					// 病理号2
					map.put("F09x02", pathologyNumber);
				}
				pathologyDiagCount++;
			}

		}

		// 中毒损伤
		List<Map<String, Object>> damageAndVenenationDiagRecords = (List<Map<String, Object>>) MapUtils
				.getObject(diseaseDiagInfoMap, "damageAndVenenationDiagRecords");
		if(CollectionUtils.isNotEmpty(damageAndVenenationDiagRecords)){
		int damageAndVenenationDiagCount = 1;
		for (Map<String, Object> damageAndVenenationDiagRecord : damageAndVenenationDiagRecords) {
			String diagCode = MapUtils.getString(damageAndVenenationDiagRecord, "diseaseDiagCode");
			String diagName = MapUtils.getString(damageAndVenenationDiagRecord, "diseaseDiagName");
			if (damageAndVenenationDiagCount == 1) {
				map.put("C12C", diagCode);
				map.put("C13N", diagName);
			}
			damageAndVenenationDiagCount++;
		}}

		// 有无药物过敏
		String whetherDrugAllergyCode = MapUtils.getString(basicInfoMap, "whetherDrugAllergyCode");
		if (StringUtils.isEmpty(whetherDrugAllergyCode)) {
			map.put("C24C", "1");
		} else {
			map.put("C24C", whetherDrugAllergyCode);
			// 过敏药物名称
			if("2".equals(whetherDrugAllergyCode)){
				map.put("C25", MapUtils.getString(basicInfoMap, "drugAllergyDesc"));
			}

		}

		// 治疗信息
		Map<String, Object> cureInfoMap = (Map<String, Object>) MapUtils.getObject(jsonMap, "cureInfo");


		// HBsAg
		map.put("F10", MapUtils.getString(cureInfoMap, "hbsAgeResultCode"));
		// HCV-Ab
		map.put("F11", MapUtils.getString(cureInfoMap, "hcvAbResultCode"));
		// HIV-Ab
		map.put("F12", MapUtils.getString(cureInfoMap, "hivAbResultCode"));
		// 医师信息
		List<Map<String, Object>> cureWorkers = (List<Map<String, Object>>) MapUtils.getObject(cureInfoMap,
				"cureWorkers");
		if(CollectionUtils.isNotEmpty(cureWorkers)){
		for (Map<String, Object> cureWorker : cureWorkers) {
			String medicalWorkerName = MapUtils.getString(cureWorker, "medicalWorkerName");
			String professionTitleCode = MapUtils.getString(cureWorker, "professionTitleCode");
//			String certificatePracticeDoctor = null;
//			String certificatePracticeNurse = null;
//			if(StringUtils.isNotBlank(medicalWorkerName)) {
//				certificatePracticeDoctor =  medicalRecordDataManageService.getCertificatePracticeByName(medicalWorkerName, 1);
//				certificatePracticeNurse =  medicalRecordDataManageService.getCertificatePracticeByName(medicalWorkerName, 2);
//			}

			//String medicalWorkerName = MapUtils.getString(medicalWork, "medicalWorkerName");
			String medicalWorkerCode = MapUtils.getString(cureWorker, "medicalWorkerCode");
			PractitionerVO practitionerVO = null;
			// 执业人员信息
			if(StringUtils.isNotBlank(medicalWorkerCode)) {
				practitionerVO = medicalRecordDataManageService.getCertificateByMedicalWorkCode(medicalWorkerCode);
			}

				// 科主任
				if ("A1001".equals(professionTitleCode)) {
					// 科主任编码
					if(StringUtils.isNotBlank(medicalWorkerName)) {
						map.put("B22C", practitionerVO!=null?practitionerVO.getCertificateNo():null);
					}

					map.put("B22", medicalWorkerName);
					// 主（副主）任医师编码 B23C 主（副主）任医师 B23
				} else if ("A2001".equals(professionTitleCode)) {
					map.put("B23C", practitionerVO!=null?practitionerVO.getCertificateNo():null);
					map.put("B23", medicalWorkerName);
					// 主治医师编码 B24C 主治医师 B24
				} else if ("A2003".equals(professionTitleCode)) {
					map.put("B24C",practitionerVO!=null?practitionerVO.getCertificateNo():null);
					map.put("B24", medicalWorkerName);
					// 住院医师编码 B25C 住院医师 B25
				} else if ("A2005".equals(professionTitleCode)) {
					map.put("B25C", practitionerVO!=null?practitionerVO.getCertificateNo():null);
					map.put("B25", medicalWorkerName);
					// 责任护士编码 B26C 责任护士 B26
				} else if ("A3001".equals(professionTitleCode)) {
					map.put("B26C", practitionerVO!=null?practitionerVO.getCertificateNo():null);
					map.put("B26", medicalWorkerName);
					// 进修医师 B27
				} else if ("A2006".equals(professionTitleCode)) {
					map.put("B27", medicalWorkerName);
					// 实习医师 B28
				} else if ("A2008".equals(professionTitleCode)) {
					map.put("B28", medicalWorkerName);
					// 编码员 B29
				} else if ("A4001".equals(professionTitleCode)) {
					map.put("B29", medicalWorkerName);
					// 质控医师 B31
				} else if ("A2009".equals(professionTitleCode)) {
					map.put("B31", medicalWorkerName);
					// 质控护师 B32
				} else if ("A3003".equals(professionTitleCode)) {
					map.put("B32", medicalWorkerName);
				}


		}}
		// 病案质量 B30C
		map.put("B30C", MapUtils.getString(cureInfoMap, "medicalRecordQualityCode"));
		// 质控日期 B33
		String qualityControlDateTime = MapUtils.getString(cureInfoMap, "qualityControlDateTime");
		if (StringUtils.isNotBlank(qualityControlDateTime)) {
			map.put("B33", qualityControlDateTime.split(" ")[0]);
		}

		// 死亡患者尸检 C34C
		map.put("C34C", MapUtils.getString(basicInfoMap, "autopsyCode"));
		// ABO血型 C26C
		map.put("C26C", MapUtils.getString(cureInfoMap, "bloodTypeCode"));
		// Rh血型 C27C
		map.put("C27C", MapUtils.getString(cureInfoMap, "rhBloodTypeCode"));

		Map<String, Object> operateInfo = (Map<String, Object>) MapUtils.getObject(jsonMap, "hqmsOperateInfo");

		List<Map<String, Object>> operateRecords = (List<Map<String, Object>>) MapUtils.getObject(operateInfo,
				"operateRecords");

		if(CollectionUtils.isEmpty(operateRecords)) {
			map.put("C14x01C", "-");
			map.put("C15x01N", "-");
			map.put("C16x01", "-");
		}else{

			for (int i = 0; i < operateRecords.size(); i++) {
				Map<String, Object> operateRecord = operateRecords.get(i);
				// 手术编码
				String operateCode = MapUtils.getString(operateRecord, "operateCode");
				// 手术名称
				String operateName = MapUtils.getString(operateRecord, "operateName");
				// 手术级别
				String opsLevelCode = MapUtils.getString(operateRecord, "opsLevelCode");
				// 手术开始时间
				String operateStartDate = MapUtils.getString(operateRecord, "operateStartDate");
				// 切口等级
				String incisionLevelCode = MapUtils.getString(operateRecord, "incisionLevelCode");
				// 麻醉方式
				String anaesthesiaTypeCode = MapUtils.getString(operateRecord, "anaesthesiaTypeCode");
				// 愈合等级
				String cicatrizeTypeCode = MapUtils.getString(operateRecord, "cicatrizeTypeCode");
				// 麻醉分级
				String anaesthesiaLevelCode = MapUtils.getString(operateRecord, "anaesthesiaLevelCode");

				String anaesthesiaCode = "";
				if(StringUtils.isNotBlank(anaesthesiaTypeCode)) {
					anaesthesiaCode = (String) getAnaesthesiaMap().get(anaesthesiaTypeCode);
					if(StringUtils.isEmpty(anaesthesiaCode)) {
						 anaesthesiaCode = "";
					}
				}

				String opDoctor = null;
				String ass1 = null;
				String ass2 = null;
				String anaDoctor = null;

				List<Map<String, Object>> operateWorkers = (List<Map<String, Object>>) MapUtils.getObject(operateRecord,
						"operateWorkers");

				for (Map<String, Object> operateWorker : operateWorkers) {
					String professionTitleCode = MapUtils.getString(operateWorker, "professionTitleCode");
					String medicalWorkerName = MapUtils.getString(operateWorker, "medicalWorkerName");
					if ("A5001".equals(professionTitleCode)) {
						opDoctor = medicalWorkerName;
					} else if ("A5003".equals(professionTitleCode)) {
						ass1 = medicalWorkerName;
					} else if ("A5004".equals(professionTitleCode)) {
						ass2 = medicalWorkerName;
					} else if ("A5002".equals(professionTitleCode)) {
						anaDoctor = medicalWorkerName;
					}

				}

				if (i == 0) {
					// 主要手术操作编码 C14x01C
					if(StringUtils.isEmpty(operateCode)) {
						map.put("C14x01C", "-");
					}else {
						map.put("C14x01C", operateCode);
					}

					// 主要手术操作名称 C15x01N
					if(StringUtils.isEmpty(operateName)) {
						map.put("C15x01N", "-");
					}else {
						map.put("C15x01N", operateName);
					}
					// 主要手术操作日期 C16x01
					map.put("C16x01", operateStartDate);
					// 主要手术操作级别 C17x01
					map.put("C17x01", opsLevelCode);
					// 主要手术持续时间 F13
					map.put("F13", null);
					// 主要手术操作术者 C18x01
					map.put("C18x01", opDoctor);
					// 主要手术操作Ⅰ助 C19x01
					map.put("C19x01", ass1);
					// 主要手术操作Ⅱ助 C20x01
					map.put("C20x01", ass2);
					// 主要手术操作切口愈合等级 C21x01C
					map.put("C21x01C", getIncisionHealLevel(incisionLevelCode,cicatrizeTypeCode));
					// 主要手术操作麻醉方式 C22x01C
					map.put("C22x01C", anaesthesiaCode);
					// 主要手术麻醉分级 F15
					map.put("F15", anaesthesiaLevelCode);
					// 主要手术操作麻醉医师 C23x01
					map.put("C23x01", anaDoctor);
				} else {
					String operationIndex = i < 10 ? "0" + i : i + "";
					// 其他手术操作编码1 C35x01C
					map.put("C35x" + operationIndex + "C", operateCode);
					// 其他手术操作名称1 C36x01N
					map.put("C36x" + operationIndex + "N", operateName);
					// 其他手术操作日期1 C37x01
					map.put("C37x" + operationIndex + "", operateStartDate);
					// 其他手术操作级别1 C38x01
					map.put("C38x" + operationIndex + "", opsLevelCode);
					// 其他手术持续时间1 F14x01
					map.put("F14x" + operationIndex + "", null);
					// 其他手术操作术者1 C39x01
					map.put("C39x" + operationIndex + "", opDoctor);
					// 其他手术操作Ⅰ助1 C40x01
					map.put("C40x" + operationIndex + "", ass1);
					// 其他手术操作Ⅱ助1 C41x01
					map.put("C41x" + operationIndex + "", ass2);
					// 其他手术操作切口愈合等级1 C42x01C
					map.put("C42x" + operationIndex + "C", getIncisionHealLevel(incisionLevelCode,cicatrizeTypeCode));
					// 其他手术操作麻醉方式1 C43x01C
					map.put("C43x" + operationIndex + "C", anaesthesiaCode);
					// 其他手术麻醉分级1 F16x01
					map.put("F16x" + operationIndex + "", anaesthesiaLevelCode);
					// 其他手术操作麻醉医师1 C44x01
					map.put("C44x" + operationIndex + "", anaDoctor);

				}


			}
		}


		Map<String,Object> nurseInfo = (Map<String, Object>) MapUtils.getObject(jsonMap, "nurseInfo");
		if(MapUtils.isNotEmpty(nurseInfo)) {
			// 特级护理天数 F17
			map.put("F17", MapUtils.getString(nurseInfo, "specialNurseDayNumber"));
			// 一级护理天数 F18
			map.put("F18", MapUtils.getString(nurseInfo, "firstLevelNurseDayNumber"));
			// 二级护理天数 F19
			map.put("F19", MapUtils.getString(nurseInfo, "secondLevelNurseDayNumber"));
			// 三级护理天数 F20
			map.put("F20", MapUtils.getString(nurseInfo, "threeLevelNurseDayNumber"));
		}
		System.out.println(1);
		Map<String, Object> infusionBloodInfo = (Map<String, Object>) MapUtils.getObject(jsonMap, "infusionBloodInfo");

		if (MapUtils.isNotEmpty(infusionBloodInfo)) {

			//输血反应次数
			Integer infusionBloodReactTimes = MapUtils.getInteger(infusionBloodInfo, "infusionBloodReactTimes");
			// 输血反应 F21
			// 0	未输
			// 1	有
			// 2	无
			if (infusionBloodReactTimes != null && infusionBloodReactTimes > 0) {
				map.put("F21", 1);
			} else {
				map.put("F21", 2);
			}
			List<Map<String, Object>> infusionBloodRecords = (List<Map<String, Object>>) MapUtils.getObject(infusionBloodInfo, "infusionBloodRecords");
			// 红细胞
			double redCellCount = 0;
			// 血小板
			double bloodCellCount = 0;
			// 血浆
			double plasmaCount = 0;
			// 全血
			double wholeBloodCount = 0;
			// 自体血回输
			double selfBloodCount = 0;
			if (CollectionUtils.isNotEmpty(infusionBloodRecords)) {
				for (Map<String, Object> infusionBloodRecord : infusionBloodRecords) {
					List<Map<String, Object>> infusionBloodElements = (List<Map<String, Object>>) MapUtils.getObject(infusionBloodRecord, "infusionBloodElements");
					for (Map<String, Object> infusionBloodElement : infusionBloodElements) {
						String bloodElementCode = MapUtils.getString(infusionBloodElement, "bloodElementCode");
						double bloodElementVolume = MapUtils.getDoubleValue(infusionBloodElement, "bloodElementVolume");
						// 红细胞
						if ("B0001".equals(bloodElementCode)) {
							redCellCount += bloodElementVolume;
							// 血小板
						} else if ("B0003".equals(bloodElementCode)) {
							bloodCellCount += bloodElementVolume;
							// 血浆
						} else if ("B0004".equals(bloodElementCode)) {
							plasmaCount += bloodElementVolume;
							// 全血
						} else if ("B0005".equals(bloodElementCode)) {
							wholeBloodCount += bloodElementVolume;
							// 自体血回输
						} else if ("B0006".equals(bloodElementCode)) {
							selfBloodCount += bloodElementVolume;
						}
					}

				}
			}
			// 红细胞 F22
			map.put("F22", Double.toString(redCellCount));
			// 血小板 F23
			map.put("F23", Double.toString(bloodCellCount));
			// 血浆 F24
			map.put("F24", Double.toString(plasmaCount));
			// 全血 F25
			map.put("F25", Double.toString(wholeBloodCount));
			// 自体血回输 F26
			map.put("F26", Double.toString(selfBloodCount));
		}else{
			// 输血反应 F21
			map.put("F21", 0);
			// 红细胞 F22
			map.put("F22", 0);
			// 血小板 F23
			map.put("F23", 0);
			// 血浆 F24
			map.put("F24", 0);
			// 全血 F25
			map.put("F25", 0);
			// 自体血回输 F26
			map.put("F26", 0);
		}

//		// 输血反应 F21
//		map.put("F21", null);
//		// 红细胞 F22
//		map.put("F22", null);
//		// 血小板 F23
//		map.put("F23", null);
//		// 血浆 F24
//		map.put("F24", null);
//		// 全血 F25
//		map.put("F25", null);
//		// 自体血回输 F26
//		map.put("F26", null);
		// 年龄不足1周岁的年龄（天） A16
		String ageYear =  MapUtils.getString(basicInfoMap, "yearOfAge");

		if(StringUtils.isEmpty(ageYear)) {
			String birthday = MapUtils.getString(basicInfoMap, "birthday");
			String inHospitalDateTime =  MapUtils.getString(basicInfoMap, "inHospitalDateTime");
			if(StringUtils.isNotBlank(inHospitalDateTime) && StringUtils.isNotBlank(birthday)) {
				map.put("A16", DateUtil.caculateTotalTime(inHospitalDateTime, birthday));
			}

		}

		map.put("A16", MapUtils.getString(basicInfoMap, "dayOfAge"));
		// 新生儿出生体重（克） A18x01
		map.put("A18x01", MapUtils.getString(cureInfoMap, "babyBirthWeight"));

		// 新生儿出生体重（克）2 A18x02
		map.put("A18x02", null);
		// 新生儿出生体重（克）3 A18x03
		map.put("A18x03", null);
		// 新生儿出生体重（克）4 A18x04
		map.put("A18x04", null);
		// 新生儿出生体重（克）5 A18x05
		map.put("A18x05", null);
		// 新生儿入院体重（克） A17
		map.put("A17", MapUtils.getString(cureInfoMap, "babyInHospitalWeight"));
		// 颅脑损伤患者入院前昏迷时间（天） C28
		String dayOfBeforeInHospitalComa = MapUtils.getString(cureInfoMap, "dayOfBeforeInHospitalComa");
		map.put("C28", StringUtils.isEmpty(dayOfBeforeInHospitalComa)?"0":dayOfBeforeInHospitalComa);
		// 颅脑损伤患者入院前昏迷时间（小时） C29
		String hourOfBeforeInHospitalComa = MapUtils.getString(cureInfoMap, "hourOfBeforeInHospitalComa");
		map.put("C29",  StringUtils.isEmpty(hourOfBeforeInHospitalComa)?"0":hourOfBeforeInHospitalComa);
		// 颅脑损伤患者入院前昏迷时间（分钟） C30
		String minuteOfBeforeInHospitalComa = MapUtils.getString(cureInfoMap, "minuteOfBeforeInHospitalComa");
		map.put("C30", StringUtils.isEmpty(minuteOfBeforeInHospitalComa)?"0":minuteOfBeforeInHospitalComa);
		// 颅脑损伤患者入院后昏迷时间（天） C31
		String dayOfAfterInHospitalComa = MapUtils.getString(cureInfoMap, "dayOfAfterInHospitalComa");
		map.put("C31", StringUtils.isEmpty(dayOfAfterInHospitalComa)?"0":dayOfAfterInHospitalComa);
		// 颅脑损伤患者入院后昏迷时间（小时） C32
		String hourOfAfterInHospitalComa = MapUtils.getString(cureInfoMap, "hourOfAfterInHospitalComa");
		map.put("C32", StringUtils.isEmpty(hourOfAfterInHospitalComa)?"0":hourOfAfterInHospitalComa);
		// 颅脑损伤患者入院后昏迷时间（分钟） C33
		String minuteOfAfterInHospitalComa = MapUtils.getString(cureInfoMap, "minuteOfAfterInHospitalComa");
		map.put("C33", StringUtils.isEmpty(minuteOfAfterInHospitalComa)?"0":minuteOfAfterInHospitalComa);
		// 有创呼吸机使用时间 C47
		map.put("C47", MapUtils.getString(cureInfoMap, "invasiveVentilatorHour"));
		// 重症监护室名称1 C48x01C
		map.put("C48x01C", MapUtils.getString(cureInfoMap, "intensiveCareUnit1Code"));
		// 进入时间1 C49x01
		map.put("C49x01", MapUtils.getString(cureInfoMap, "intensiveCareUnit1StartTime"));
		// 退出时间1 C50x01
		map.put("C50x01", MapUtils.getString(cureInfoMap, "intensiveCareUnit1EndTime"));
		// 重症监护室名称2 C48x02C
		map.put("C48x02C", MapUtils.getString(cureInfoMap, "intensiveCareUnit2Code"));
		// 进入时间2 C49x02
		map.put("C49x02", MapUtils.getString(cureInfoMap, "intensiveCareUnit2StartTime"));
		// 退出时间2 C50x02
		map.put("C50x02", MapUtils.getString(cureInfoMap, "intensiveCareUnit2EndTime"));
		// 重症监护室名称3 C48x03C
		map.put("C48x03C", MapUtils.getString(cureInfoMap, "intensiveCareUnit3Code"));
		// 进入时间3 C49x03
		map.put("C49x03", MapUtils.getString(cureInfoMap, "intensiveCareUnit3StartTime"));
		// 退出时间3 C50x03
		map.put("C50x03", MapUtils.getString(cureInfoMap, "intensiveCareUnit3EndTime"));
		// 重症监护室名称4 C48x04C
		map.put("C48x04C", null);
		// 进入时间4 C49x04
		map.put("C49x04", null);
		// 退出时间4 C50x04
		map.put("C50x04", null);
		// 重症监护室名称5 C48x05C
		map.put("C48x05C", null);
		// 进入时间5 C49x05
		map.put("C49x05", null);
		// 退出时间5 C50x05
		map.put("C50x05", null);
		// 是否有出院31日内再住院计划 B36C
		map.put("B36C", MapUtils.getString(cureInfoMap, "rehospitalAimOf31Code"));
		// 出院31天再住院计划目的 B37
		map.put("B37", MapUtils.getString(cureInfoMap, "rehospitalAimOf31Description"));
		// 离院方式 B34C
		map.put("B34C", MapUtils.getString(basicInfoMap, "outHospitalTypeCode"));
		// 医嘱转院、转社区卫生服务机构/乡镇卫生院名称 B35
		map.put("B35", MapUtils.getString(basicInfoMap, "shiftToUnitName"));

		Map<String, Object> costInfoMap = (Map<String, Object>) MapUtils.getObject(jsonMap, "costInfo");
		if (MapUtils.isNotEmpty(costInfoMap)) {
			// 住院总费用 D01
			map.put("D01", MapUtils.getString(costInfoMap, "totalCost"));
			// 住院总费用其中自付金额 D09
			map.put("D09", MapUtils.getString(costInfoMap, "selfCost"));

			List<Map<String, Object>> costRecords = (List<Map<String, Object>>) MapUtils.getObject(costInfoMap,
					"costRecords");

			for (Map<String, Object> costRecord : costRecords) {
				String costMoney = MapUtils.getString(costRecord, "costMoney");
				String medicalCostTypeCode = MapUtils.getString(costRecord, "medicalCostTypeCode");
				if(StringUtils.isEmpty(costMoney)) {
					costMoney ="0";
				}
				// //1.一般医疗服务费 D11
				if ("C01001".equals(medicalCostTypeCode)) {
					map.put("D11", costMoney);
					// 2.一般治疗操作费 D12
				} else if ("C01002".equals(medicalCostTypeCode)) {
					map.put("D12", costMoney);
					// 3.护理费 D13
				} else if ("C01003".equals(medicalCostTypeCode)) {
					map.put("D13", costMoney);
					// 4.综合医疗服务类其他费用 D14
				} else if ("C01999".equals(medicalCostTypeCode)) {
					map.put("D14", costMoney);
					// 5.病理诊断费 D15
				} else if ("C02001".equals(medicalCostTypeCode)) {
					map.put("D15", costMoney);
					// 6.实验室诊断费 D16
				} else if ("C02002".equals(medicalCostTypeCode)) {
					map.put("D16", costMoney);
					// 7.影像学诊断费 D17
				} else if ("C02003".equals(medicalCostTypeCode)) {
					map.put("D17", costMoney);
					// 8.临床诊断项目费 D18
				} else if ("C02004".equals(medicalCostTypeCode)) {
					map.put("D18", costMoney);
					// 9.非手术治疗项目费 D19
				} else if ("C03001".equals(medicalCostTypeCode)) {
					map.put("D19", costMoney);
					// 其中：临床物理治疗费 D19x01
				} else if ("C03002".equals(medicalCostTypeCode)) {
					map.put("D19x01", costMoney);
					// 10.手术治疗费 D20
				} else if ("C03003".equals(medicalCostTypeCode)) {
					map.put("D20", costMoney);
					// 其中：麻醉费 D20x01
				} else if ("C03004".equals(medicalCostTypeCode)) {
					map.put("D20x01", costMoney);
					// 其中：手术费 D20x02
				} else if ("C03005".equals(medicalCostTypeCode)) {
					map.put("D20x02", costMoney);
					// 11.康复费 D21
				} else if ("C04001".equals(medicalCostTypeCode)) {
					map.put("D21", costMoney);
					// 12.中医治疗费 D22
				} else if ("C05001".equals(medicalCostTypeCode)) {
					map.put("D22", costMoney);
					// 13.西药费 D23
				} else if ("C06001".equals(medicalCostTypeCode)) {
					map.put("D23", costMoney);
					// 其中：抗菌药物费 D23x01
				} else if ("C06002".equals(medicalCostTypeCode)) {
					map.put("D23x01", costMoney);
					// 14.中成药费 D24
				} else if ("C07001".equals(medicalCostTypeCode)) {
					map.put("D24", costMoney);
					// 15.中草药费 D25
				} else if ("C07002".equals(medicalCostTypeCode)) {
					map.put("D25", costMoney);
					// 16.血费 D26
				} else if ("C08001".equals(medicalCostTypeCode)) {
					map.put("D26", costMoney);
					// 17.白蛋白类制品费 D27
				} else if ("C08002".equals(medicalCostTypeCode)) {
					map.put("D27", costMoney);
					// 18.球蛋白类制品费 D28
				} else if ("C08003".equals(medicalCostTypeCode)) {
					map.put("D28", costMoney);
					// 19.凝血因子类制品费 D29
				} else if ("C08004".equals(medicalCostTypeCode)) {
					map.put("D29", costMoney);
					// 20.细胞因子类制品费 D30
				} else if ("C08005".equals(medicalCostTypeCode)) {
					map.put("D30", costMoney);
					// 21.检查用一次性医用材料费 D31
				} else if ("C09001".equals(medicalCostTypeCode)) {
					map.put("D31", costMoney);
					// 22.治疗用一次性医用材料费 D32
				} else if ("C09002".equals(medicalCostTypeCode)) {
					map.put("D32", costMoney);
					// 23.手术用一次性医用材料费 D33
				} else if ("C09003".equals(medicalCostTypeCode)) {
					map.put("D33", costMoney);
					// 24.其他费： D34
				} else if ("C99999".equals(medicalCostTypeCode)) {
					map.put("D34", costMoney);
				}
			}

		}

		return map;

	}

	@ResponseBody
	@RequestMapping("/exportHqmsHomepage")
	public void exportHqmsHomepage(String startTime,String endTime, HttpServletResponse response,
			HttpServletRequest request) {
		// 解决跨域问题
		response.setHeader("Access-Control-Allow-Origin", "*");
		try {
			String fileName = "hqmsts_"+startTime+"-"+endTime;
			String startDate = startTime+" 00:00:00";
			String endDate = endTime+" 23:59:59";

			exportBatch(response, startDate,endDate,hqmsHomePageHeader,
					fileName);

		} catch (Exception e) {
			e.printStackTrace();

		}

	}


	/**
	 * 导出报表
	 *
	 * @param response
	 * @param header
	 * @param fileName
	 * @throws IOException
	 */
	private void exportBatch(HttpServletResponse response, String startDate,String endDate, String[] header,
			String fileName) throws IOException {
		response.setContentType("application/vnd.ms-excel;charset=GBK");
		response.setHeader("Content-Disposition",
				"attachment;filename=" + new String((fileName).getBytes("GBK"), "ISO8859-1") + "." + "csv");
		response.setCharacterEncoding("UTF-8");
		StringBuilder sb = new StringBuilder();
		for (String s : header) {
			sb.append("\t").append(s).append(",");
		}
		sb.append("\n");
		OutputStream out = response.getOutputStream();
		try {
			out.write(new byte[] { (byte) 0xEF, (byte) 0xBB, (byte) 0xBF });
			out.write(sb.toString().getBytes());
			int pageNumber = 1;
			int pageSize = 1000;
			int dataLength = pageSize;
			while (dataLength == pageSize) {
				int startIndex = (pageNumber - 1) * pageSize;
				int endIndex = pageSize;


				// 分页查询数据
				List<Map<String,Object>> resultList = getHqmsHomepageData(startDate,endDate,startIndex,endIndex);

				dataLength = resultList.size();

				for (int i = 0; i < dataLength; i++) {
					// 解决乱码
					out.write(new byte[] { (byte) 0xEF, (byte) 0xBB, (byte) 0xBF });
					out.write(CSVUtil.handleExportData(resultList.get(i), header).getBytes("UTF-8"));
				}
				out.flush();
				pageNumber++;
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (out != null) {
				out.close();
			}
		}
	}

	public List<Map<String,Object>> getHqmsHomepageData(String startDate,String endDate,int startIndex,int endIndex){
		List<Map<String,Object>> mapList = new ArrayList<>();
		List<String> guidList = medicalRecordDataManageService.getMedicalRecordJsonByPage(startDate, endDate, startIndex, endIndex);
//		List<String> guidList = new ArrayList<>();
//		guidList.add("1e4444e596e34a838e8284509fac9242");
		for (String guid : guidList) {
			String json = medicalRecordDataManageService.getMedicalRecordJsonByGuid(guid);
			if(StringUtils.isNotBlank(json)) {
				mapList.add(getHqmsDataByJson(json));
			}
		}

		return mapList;
	}


}
